Skip to content

Instantly share code, notes, and snippets.

@vedon
Last active June 9, 2020 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedon/fee234d39ed7ab2a2d45603867317989 to your computer and use it in GitHub Desktop.
Save vedon/fee234d39ed7ab2a2d45603867317989 to your computer and use it in GitHub Desktop.
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