Last active
June 9, 2020 08:58
-
-
Save vedon/fee234d39ed7ab2a2d45603867317989 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class AppContext { | |
let container: DIContainer | |
init() { | |
self.container = DIContainer.init() | |
ServiceAssembly.assembled(in: container) | |
} | |
} | |
enum ServiceAssembly { | |
static func assembled(in container: DIContainer) { | |
container.register(Feature1Service.self) { (_) -> Feature1Service in | |
return Feature1() | |
} | |
container.register(User.self) { (_) -> User in | |
return UserSession() | |
} | |
container.register(Feature3Service.self) { (resolver) -> Feature3Service in | |
let user = resolver.resolve(User.self) | |
return Feature3(user!) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment