Dependency Injection for Swift Developers

Поделиться
HTML-код
  • Опубликовано: 10 дек 2024

Комментарии • 11

  • @compsci-guy
    @compsci-guy Месяц назад

    Great description and clarity. 👍

  • @Xaxxus
    @Xaxxus 2 месяца назад

    I definitely prefer the service locator pattern.
    Sure you can get a crash if you forget a dependency, but that’s something that you should be picking up during development.

  • @Skwiggs
    @Skwiggs Месяц назад

    What's preventing you from just using the view model factory approach, and make that factory an environment object? Then any view that needs to instantiate another can just refer to factory from its environment

    • @DonnyWalsdev
      @DonnyWalsdev  Месяц назад

      Nothing, it’d be just another flavor of passing a factory around

  • @Avolua
    @Avolua Месяц назад

    I think this throws some warning when swift 6 and complete modes enabled. I was hoping for something compatible with swift 6

    • @DonnyWalsdev
      @DonnyWalsdev  Месяц назад

      Neither DI approach is incompatible with Swift, what kinds of warnings do you get?

    • @Avolua
      @Avolua Месяц назад

      @@DonnyWalsdev
      Static property 'current' is not concurrency-safe because it is nonisolated global shared mutable state;
      this is an error in Swift 6 language mode.

    • @DonnyWalsdev
      @DonnyWalsdev  Месяц назад

      @@Avolua ah I see, so that’s entirely unrelated to how you do DI. The compiler is complaining about that property being mutable without any means to ensure data race safety. Making current a let should work, or converting whatever holds that property to an actor might work too.
      It’s a bit of an annoying error that one because sometimes fixing it will mean you’ll have to move away from static vars (or marking those vars as nonisolated(unsafe))

  • @EustakioXC
    @EustakioXC 2 месяца назад +2

    There is something weird with the audio processing

    • @DonnyWalsdev
      @DonnyWalsdev  2 месяца назад

      Yeah I’m not exactly sure what got messed up in processing. The initial upload I had was completely out of sync. This one’s much better in terms of syncing but there’s still something off and I have no idea what it is exactly 😅