Using Closures as Dependencies

Sdílet
Vložit
  • čas přidán 20. 06. 2024
  • In this video we'll explore an alternative way of injecting functionality into your objects. You'll see how you can use closures to inject only the functionality you really need rather than an entire object which makes scoping your dependencies much easier, as well as improving composability and testability of your code.
    This video is a companion video for the following blog post: www.donnywals.com/using-closu...
    Check out my Swift Concurrency course right here: donnyplus.com/p/practical-swi...
  • Jak na to + styl

Komentáře • 6

  • @weeee733
    @weeee733 Před 2 měsíci

    Thanks for the tip! Also these closures make use of withContinuation methods)

  • @victorriurean
    @victorriurean Před 2 měsíci +1

  • @jyotinkarpandey
    @jyotinkarpandey Před 2 měsíci +1

    Can we have a sample project link ?

    • @DonnyWalsdev
      @DonnyWalsdev  Před 2 měsíci

      Hey! So sorry, I don't have a (publicly available) sample project available for this.

  • @loganblevins8633
    @loganblevins8633 Před 2 měsíci

    Nice video! Why not make a smaller protocol only giving the needed capability and then make the other protocol conform to the smaller if needed?

    • @DonnyWalsdev
      @DonnyWalsdev  Před 2 měsíci +1

      You'd end up with loads of small protocols that are composed into larger ones when needed. This can certainly help with scoping and mocking, but at the same time having so many protocols can be quite unwieldy; especially when an object needs to have a composition of parts of protocols and you end up having to break things down even further.
      Of course, it might make more sense for some codebases then others. This is just one tool in your toolbelt for injecting and composing dependencies