DIContainer

interface DIContainer

The Container is the entry point for retrieval without DI's inline & reified shenanigans.

In DI, every binding is stored as a factory. Providers are special classes of factories that take Unit as parameter.

Types

Builder
Link copied to clipboard
common
interface Builder

This is where you configure the bindings.

Functions

allFactories
Link copied to clipboard
common
abstract fun <C : Any, A, T : Any> allFactories(key: DI.Key<C, A, T>, context: C, overrideLevel: Int = 0): List<(A) -> T>

Retrieve all factories that match the given key.

allProviders
Link copied to clipboard
common
open fun <C : Any, T : Any> allProviders(key: DI.Key<C, Unit, T>, context: C, overrideLevel: Int = 0): List<() -> T>

Retrieve all providers that match the given key.

factory
Link copied to clipboard
common
abstract fun <C : Any, A, T : Any> factory(key: DI.Key<C, A, T>, context: C, overrideLevel: Int = 0): (A) -> T

Retrieve a factory for the given key.

factoryOrNull
Link copied to clipboard
common
abstract fun <C : Any, A, T : Any> factoryOrNull(key: DI.Key<C, A, T>, context: C, overrideLevel: Int = 0): (A) -> T?

Retrieve a factory for the given key, or null if none is found.

provider
Link copied to clipboard
common
open fun <C : Any, T : Any> provider(key: DI.Key<C, Unit, T>, context: C, overrideLevel: Int = 0): () -> T

Retrieve a provider for the given key.

providerOrNull
Link copied to clipboard
common
open fun <C : Any, T : Any> providerOrNull(key: DI.Key<C, Unit, T>, context: C, overrideLevel: Int = 0): () -> T?

Retrieve a provider for the given key, or null if none is found.

Properties

tree
Link copied to clipboard
common
abstract val tree: DITree

The tree that contains all bindings.