BindingDI

interface BindingDI<out C : Any> : DirectDI, WithContext<C>

Direct DI interface to be passed to factory methods that hold references.

It is augmented to allow such methods to access the context of the retrieval, as well as a factory from the binding it is overriding (if it is overriding).

Parameters

C

The type of the context

Functions

Factory
Link copied to clipboard
common
abstract fun <A, T : Any> Factory(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null): (A) -> T

Gets a factory of T for the given argument type, return type and tag.

FactoryOrNull
Link copied to clipboard
common
abstract fun <A, T : Any> FactoryOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null): (A) -> T?

Gets a factory of T for the given argument type, return type and tag, or null if none is found.

Instance
Link copied to clipboard
common
abstract fun <T : Any> Instance(type: TypeToken<T>, tag: Any? = null): T

Gets an instance of T for the given type and tag.

abstract fun <A, T : Any> Instance(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: A): T

Gets an instance of T for the given type and tag, curried from a factory for the given argument type.

InstanceOrNull
Link copied to clipboard
common
abstract fun <T : Any> InstanceOrNull(type: TypeToken<T>, tag: Any? = null): T?

Gets an instance of T for the given type and tag, or null if none is found.

abstract fun <A, T : Any> InstanceOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: A): T?

Gets an instance of T for the given type and tag, curried from a factory for the given argument type, or null if none is found.

On
Link copied to clipboard
common
abstract fun On(context: DIContext<*>): DirectDI

Returns a DirectDI with its context changed.

onErasedContext
Link copied to clipboard
common
abstract fun onErasedContext(): BindingDI<C>
overriddenFactory
Link copied to clipboard
common
abstract fun overriddenFactory(): (Any?) -> Any

Gets a factory from the overridden binding.

overriddenFactoryOrNull
Link copied to clipboard
common
abstract fun overriddenFactoryOrNull(): (Any?) -> Any?

Gets a factory from the overridden binding, if this binding overrides an existing binding.

Provider
Link copied to clipboard
common
abstract fun <T : Any> Provider(type: TypeToken<T>, tag: Any? = null): () -> T

Gets a provider of T for the given type and tag.

abstract fun <A, T : Any> Provider(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: () -> A): () -> T

Gets a provider of T for the given type and tag, curried from a factory for the given argument type.

ProviderOrNull
Link copied to clipboard
common
abstract fun <T : Any> ProviderOrNull(type: TypeToken<T>, tag: Any? = null): () -> T?

Gets a provider of T for the given type and tag, or null if none is found.

abstract fun <A, T : Any> ProviderOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: () -> A): () -> T?

Gets a provider of T for the given type and tag, curried from a factory for the given argument type, or null if none is found.

Properties

container
Link copied to clipboard
common
abstract val container: DIContainer

Every methods eventually ends up to a call to this container.

context
Link copied to clipboard
common
abstract val context: C

The context that was given at retrieval.

di
Link copied to clipboard
common
open val di: DI

Returns a regular DI instance (DI is lazy by default).

directDI
Link copied to clipboard
common
abstract val directDI: DirectDI

A Direct DI Aware class must be within reach of a DirectDI object.

lazy
Link copied to clipboard
common
abstract val lazy: DI

Returns a regular DI instance (DI is lazy by default).