DirectDI

interface DirectDI : DirectDIBase

D stands for Direct. Direct DI!

Acts like a DI object but returns factories, providers and instances instead of returning property delegates. In essence, a DirectDI is used with = instead of with by.

Note that DirectDI is engineered to also work with Java code.

interface DirectDI : DirectDIBase
interface DirectDI : DirectDIBase
interface DirectDI : DirectDIBase

Functions

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

Gets all factories that can return a T for the given argument type, return type and tag.

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

Gets all instances that can return a T for the given type and tag.

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

Gets all instances that can return a T for the given type and tag, curried from factories for the given argument type.

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

Gets all providers that can return a T for the given type and tag.

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

Gets all providers that can return a T for the given type and tag, curried from factories for the given argument type.

Factory
Link copied to clipboard
abstract fun <A, T : Any> Factory(argType: <ERROR CLASS><in A>, type: <ERROR CLASS><T>, tag: Any? = null): (A) -> T
abstract fun <A, T : Any> Factory(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null): (A) -> T
abstract fun <A, T : Any> Factory(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null): (A) -> T
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
abstract fun <A, T : Any> FactoryOrNull(argType: <ERROR CLASS><in A>, type: <ERROR CLASS><T>, tag: Any? = null): (A) -> T?
abstract fun <A, T : Any> FactoryOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null): (A) -> T?
abstract fun <A, T : Any> FactoryOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null): (A) -> T?
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
abstract fun <T : Any> Instance(type: <ERROR CLASS><T>, tag: Any? = null): T
abstract fun <T : Any> Instance(type: TypeToken<T>, tag: Any? = null): T
abstract fun <T : Any> Instance(type: TypeToken<T>, tag: Any? = null): T
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: <ERROR CLASS><in A>, type: <ERROR CLASS><T>, tag: Any? = null, arg: A): T
abstract fun <A, T : Any> Instance(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: A): T
abstract fun <A, T : Any> Instance(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: A): T
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
abstract fun <T : Any> InstanceOrNull(type: <ERROR CLASS><T>, tag: Any? = null): T?
abstract fun <T : Any> InstanceOrNull(type: TypeToken<T>, tag: Any? = null): T?
abstract fun <T : Any> InstanceOrNull(type: TypeToken<T>, tag: Any? = null): T?
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: <ERROR CLASS><in A>, type: <ERROR CLASS><T>, tag: Any? = null, arg: A): T?
abstract fun <A, T : Any> InstanceOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: A): T?
abstract fun <A, T : Any> InstanceOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: A): T?
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
abstract fun On(context: DIContext<*>): DirectDI
abstract fun On(context: DIContext<*>): DirectDI
abstract fun On(context: DIContext<*>): DirectDI
abstract fun On(context: DIContext<*>): DirectDI

Returns a DirectDI with its context changed.

Provider
Link copied to clipboard
abstract fun <T : Any> Provider(type: <ERROR CLASS><T>, tag: Any? = null): () -> T
abstract fun <T : Any> Provider(type: TypeToken<T>, tag: Any? = null): () -> T
abstract fun <T : Any> Provider(type: TypeToken<T>, tag: Any? = null): () -> T
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: <ERROR CLASS><in A>, type: <ERROR CLASS><T>, tag: Any? = null, arg: () -> A): () -> T
abstract fun <A, T : Any> Provider(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: () -> A): () -> T
abstract fun <A, T : Any> Provider(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: () -> A): () -> T
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
abstract fun <T : Any> ProviderOrNull(type: <ERROR CLASS><T>, tag: Any? = null): () -> T?
abstract fun <T : Any> ProviderOrNull(type: TypeToken<T>, tag: Any? = null): () -> T?
abstract fun <T : Any> ProviderOrNull(type: TypeToken<T>, tag: Any? = null): () -> T?
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: <ERROR CLASS><in A>, type: <ERROR CLASS><T>, tag: Any? = null, arg: () -> A): () -> T?
abstract fun <A, T : Any> ProviderOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: () -> A): () -> T?
abstract fun <A, T : Any> ProviderOrNull(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: () -> A): () -> T?
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.

container
Link copied to clipboard
native
abstract val container: DIContainer

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

container
Link copied to clipboard
js
abstract val container: DIContainer

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

container
Link copied to clipboard
abstract val container: DIContainer

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

di
Link copied to clipboard
common
open val di: DI

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

di
Link copied to clipboard
native
open val di: DI

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

di
Link copied to clipboard
js
open val di: DI

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

di
Link copied to clipboard
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.

directDI
Link copied to clipboard
native
abstract val directDI: DirectDI

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

directDI
Link copied to clipboard
js
abstract val directDI: DirectDI

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

directDI
Link copied to clipboard
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).

lazy
Link copied to clipboard
native
abstract val lazy: DI

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

lazy
Link copied to clipboard
js
abstract val lazy: DI

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

lazy
Link copied to clipboard
abstract val lazy: DI

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

Inheritors

BindingDI
Link copied to clipboard
NoArgBindingDI
Link copied to clipboard

Extensions

allFactories
Link copied to clipboard
inline fun <A : Any, T : Any> DirectDI.allFactories(tag: Any? = null): List<(A) -> T>

Gets all factories that can return a T for the given argument type, return type and tag.

factory
Link copied to clipboard
inline fun <A : Any, T : Any> DirectDI.factory(tag: Any? = null): (A) -> T

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