clean-architecture-swiftui icon indicating copy to clipboard operation
clean-architecture-swiftui copied to clipboard

DIContainer conforming EnvironmentKey - can't find its usage

Open vanjang opened this issue 1 year ago • 2 comments

Just wonder why DIContainer conforms EnvironmentKey in the project as I am not able to find its usage with EnviromentValues across the project. The projects builds fine with commenting EnvironmentKey. Could anyone explain? I don't have enough knowledge on EnvironmentKey therefore I may miss something on how to use it.

vanjang avatar Feb 27 '24 15:02 vanjang

Check the RootViewModifier on the master branch, it uses: @Environment(\.injected) private var injected: DIContainer

which uses the extension EnvironmentValues { var injected: DIContainer { get { self[DIContainer.self] } set { self[DIContainer.self] = newValue } } }

from the DependencyInjector.

Eirias avatar Feb 27 '24 15:02 Eirias

Ah got it! I am on mvvm branch and it doesn't have the code you advised above. Thanks and problem solved!

vanjang avatar Feb 27 '24 16:02 vanjang