Skip to content

Injections Handling

apleshkov edited this page Jul 30, 2018 · 2 revisions

To handle the completion of property/method injections add a new method to your service with the @saber.didInject annotation.

Only one method is supported and it'll be called if there's at least one property or method injection.

// @saber.scope(App)
class StorageManager {

    // @saber.inject
    var logger: Logging?

    private var fileManager: FileManager?

    // @saber.inject
    func set(fileManager: FileManager) {
        self.fileManager = fileManager
    }

    // @saber.didInject
    func postInit() {
        print(logger)
        print(fileManager)
    }
}
Clone this wiki locally