-
Notifications
You must be signed in to change notification settings - Fork 3
Initializer Injections
apleshkov edited this page Jul 30, 2018
·
2 revisions
This type of injection brings dependencies as parameters of a service initializer.
// @saber.scope(App)
class UserManager {
private let networkManager: NetworkManager
private let userStorage: UserStorage
// @saber.inject
init(networkManager: NetworkManager, userStorage: UserStorage) {
self.networkManager = networkManager
self.userStorage = userStorage
}
}
Such initializers are usually marked with the @saber.inject
annotation. If your service has no explicit initializers, Saber will use a default one - init()
.
Also it's possible to not annotate a sole initializer (not preferable in terms of documenting your code).
- User's Guide
- Advanced