Created
December 20, 2020 15:58
-
-
Save bigMOTOR/de7b0811f05f0900396c097a5ebaf71a to your computer and use it in GitHub Desktop.
2020-12-20_Article_SwiftUInCleanArchitecture_2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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