AliSoftware/Dip

About SwiftUI

KirillSaltykov opened this issue · 1 comments

Hello!
How can I use this library with SwiftUI?
With Storyboards I can use @Injected and register(storyboardType:), but what can I do, when using SwiftUI?

I didn't have a hands-on experience with SwiftUI yet but from what I've seen my best guess would be to use Dip via Environment somehow. I would advice against putting the whole container in the environment and instead declare the dependencies of your SwiftUI views explicitly and only use container under the hood to provide the actual instances for the dependencies. This will ensure that you don't directly depend on Dip in your views. Using @injected of course goes against that for the sake of ergonomics, so using Environment only somehow and only use Dip to provide instances for the environment would be the direction I would explore.