nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DIContainer conforming EnvironmentKey - can't find its usage

vanjang opened this issue · 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.

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.

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