DirectDI

actual interface DirectDI
expect interface DirectDI : DirectDIBase
actual interface DirectDI : DirectDIBase
actual 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.

Inheritors

Properties

Link copied to clipboard
abstract val container: DIContainer
abstract val container: DIContainer
abstract val container: DIContainer

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

Link copied to clipboard
open val di: DI
open val di: DI
open val di: DI

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

Link copied to clipboard
abstract val directDI: DirectDI
abstract val directDI: DirectDI
abstract val directDI: DirectDI

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

Link copied to clipboard
abstract val lazy: DI
abstract val lazy: DI
abstract val lazy: DI

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

Link copied to clipboard

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

Functions

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.

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.

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.

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.

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

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.

inline fun <A : Any, T : Any> DirectDIAware.factory(tag: Any? = null): (A) -> T

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

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

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

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

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

Link copied to clipboard
inline fun <T : Any> DirectDIAware.instance(tag: Any? = null): T

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

inline fun <A : Any, T : Any> DirectDIAware.instance(tag: Any? = null, arg: A): T
inline fun <A, T : Any> DirectDIAware.instance(tag: Any? = null, arg: Typed<A>): T

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

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

Link copied to clipboard
inline fun <T : Any> DirectDIAware.instanceOrNull(tag: Any? = null): T?

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

inline fun <A : Any, T : Any> DirectDIAware.instanceOrNull(tag: Any? = null, arg: A): T?
inline fun <A, T : Any> DirectDIAware.instanceOrNull(tag: Any? = null, arg: Typed<A>): T?

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

Link copied to clipboard
inline fun <T> DirectDIAware.new(constructor: () -> T): T

Auto resolve a class dependencies by using its constructor reference. The resolution is done at compile time by leveraging inline functions, no reflection is required.

inline fun <T, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> DirectDIAware.new(constructor: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> T): T
inline fun <T, P1> DirectDIAware.new(constructor: (P1) -> T): T
inline fun <T, P1, P2> DirectDIAware.new(constructor: (P1, P2) -> T): T
inline fun <T, P1, P2, P3> DirectDIAware.new(constructor: (P1, P2, P3) -> T): T
inline fun <T, P1, P2, P3, P4> DirectDIAware.new(constructor: (P1, P2, P3, P4) -> T): T
inline fun <T, P1, P2, P3, P4, P5> DirectDIAware.new(constructor: (P1, P2, P3, P4, P5) -> T): T
inline fun <T, P1, P2, P3, P4, P5, P6> DirectDIAware.new(constructor: (P1, P2, P3, P4, P5, P6) -> T): T
inline fun <T, P1, P2, P3, P4, P5, P6, P7> DirectDIAware.new(constructor: (P1, P2, P3, P4, P5, P6, P7) -> T): T
inline fun <T, P1, P2, P3, P4, P5, P6, P7, P8> DirectDIAware.new(constructor: (P1, P2, P3, P4, P5, P6, P7, P8) -> T): T
inline fun <T, P1, P2, P3, P4, P5, P6, P7, P8, P9> DirectDIAware.new(constructor: (P1, P2, P3, P4, P5, P6, P7, P8, P9) -> T): T
Link copied to clipboard
inline fun <T> DirectDIAware.newInstance(creator: DirectDI.() -> T): T

Allows the creation of a new instance with DI injection.

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

Link copied to clipboard
inline fun <C : Any> DirectDIAware.on(context: C): DirectDI

Returns a DirectDI with its context and/or receiver changed.

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

Link copied to clipboard
inline fun <T : Any> DirectDIAware.provider(tag: Any? = null): () -> T

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

inline fun <A : Any, T : Any> DirectDIAware.provider(tag: Any? = null, arg: A): () -> T
inline fun <A : Any, T : Any> DirectDIAware.provider(tag: Any? = null, noinline fArg: () -> A): () -> T
inline fun <A, T : Any> DirectDIAware.provider(tag: Any? = null, arg: Typed<A>): () -> T

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

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

Link copied to clipboard
inline fun <T : Any> DirectDIAware.providerOrNull(tag: Any? = null): () -> T?

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

inline fun <A : Any, T : Any> DirectDIAware.providerOrNull(tag: Any? = null, arg: A): () -> T?
inline fun <A : Any, T : Any> DirectDIAware.providerOrNull(tag: Any? = null, noinline fArg: () -> A): () -> T?
inline fun <A, T : Any> DirectDIAware.providerOrNull(tag: Any? = null, arg: Typed<A>): () -> T?

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