Skip to content

Injecting Containers

apleshkov edited this page Aug 1, 2018 · 1 revision

Saber supports an injection of containers to your services. It could be parent containers or even a container which a service belongs to.

// @saber.container(AppContainer)
// @saber.scope(App)
protocol AppContaining {
}

// MARK: Service

// @saber.scope(App)
// @saber.cached
class Foo {

    // @saber.inject
    unowned var appContainer: AppContainer!
    // ^ avoiding a ref cyclic
}
Clone this wiki locally