Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bigMOTOR/de7b0811f05f0900396c097a5ebaf71a to your computer and use it in GitHub Desktop.
Save bigMOTOR/de7b0811f05f0900396c097a5ebaf71a to your computer and use it in GitHub Desktop.
2020-12-20_Article_SwiftUInCleanArchitecture_2
struct AppEnvironment {
let container: DIContainer
}
struct DIContainer: EnvironmentKey {
let repositories: Repositories
static var defaultValue: Self { DIContainer(repositories: Repositories()) }
}
extension EnvironmentValues {
var diContainer: DIContainer {
get { self[DIContainer.self] }
set { self[DIContainer.self] = newValue }
}
}
final class Repositories {
lazy var timerRepository: TimerRepositoryType = {
return TickTimer()
}()
lazy var colorRepository: ColorRepositoryType = {
return AvailableColors()
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment