Package-level declarations

Types

Link copied to clipboard
typealias BindingsMap = Map<DI.Key<*, *, *>, List<DIDefinition<*, *, *>>>

A Map containing all bindings associated to their keys

Link copied to clipboard
interface Copy

Simple interface that returns a the keys to copy from a container.

Link copied to clipboard
class CopySpecs(val all: Boolean) : SearchSpecs

Defines which bindings are to be copied from a parent DI to a child DI.

Link copied to clipboard
interface DI : DIAware

KOtlin DEpendency INjection.

Link copied to clipboard
interface DIAware

Any class that extends this interface can use DI "seamlessly".

Link copied to clipboard
interface DIContainer

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

Link copied to clipboard
interface DIContext<C : Any>

Defines a context and its type to be used by Di

Link copied to clipboard
open class DIDefining<C : Any, A, T : Any>(val binding: DIBinding<C, A, T>, val fromModule: String?)

A binding that is being defined inside a DI.Builder bloc.

Link copied to clipboard
class DIDefinition<C : Any, A, T : Any>(binding: DIBinding<C, A, T>, fromModule: String?, val tree: DITree) : DIDefining<C, A, T>

A definition is a binding that is associated to a DITree.

Link copied to clipboard
class DIProperty<out V>(trigger: DITrigger?, val originalContext: DIContext<*>, get: (DIContext<*>, String) -> V) : LazyDelegate<V>

A property delegate provider for DI retrieval. Provides a Lazy value that, when accessed, retrieve the value from DI.

Link copied to clipboard
class DIPropertyMap<in I, out O>(base: DIProperty<I>, map: (I) -> O) : LazyDelegate<O>
Link copied to clipboard
actual interface DirectDI
expect interface DirectDI : DirectDIBase
actual interface DirectDI : DirectDIBase
actual interface DirectDI : DirectDIBase

D stands for Direct. Direct DI!

Link copied to clipboard
interface DirectDIAware

Any class that extends this interface can use direct DI "seamlessly".

Link copied to clipboard
Link copied to clipboard
interface DITree

Tree where the bindings and their factories are sorted & stored.

Link copied to clipboard
class DITrigger

A trigger is used to force retrieval at a given time rather than at first property access.

Link copied to clipboard

DSL to find bindings.

Link copied to clipboard
class LateInitDI : DI

DI object that defers all method to a base DI object that can be set later.

Link copied to clipboard
interface LazyDelegate<out V>
Link copied to clipboard
class LazyDI(f: () -> DI) : DI

DI object that defers all method to a DI object that will be created only upon first retrieval.

Link copied to clipboard
value class Named(val di: DIAware)
Link copied to clipboard
open class SearchDSL

DSL that facilitates the creation of a SearchSpecs object.

Link copied to clipboard
open class SearchSpecs(var contextType: TypeToken<*>? = null, var argType: TypeToken<*>? = null, var type: TypeToken<*>? = null, var tag: Any? = NoDefinedTag)

Defines the specs to search bindings from (in)complete data with CopySpecs or DITree.find.

Link copied to clipboard

Soft Reference Maker.

Link copied to clipboard

Thread Local Reference Maker.

Link copied to clipboard
interface Typed<A>

Used as an argument for currying functions, allows to define a value and its type.

Link copied to clipboard

Weak Reference Maker.

Properties

Link copied to clipboard

Return a direct DirectDI instance, with its receiver and context set to this DIAware receiver and context.

Link copied to clipboard

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

Link copied to clipboard

Allows to get factories / providers / instances with a tag set to the name of the receiving property.

Functions

Link copied to clipboard
inline fun <T : Any> DI.Builder.addInBindSet(tag: Any? = null, overrides: Boolean? = null, creator: () -> DIBinding<*, *, T>)

Defines that the binding will be saved in a set binding.

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

Gets all factories that match the the given argument type, return type and tag.

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

Gets all factories that match the the given argument type, return type and tag.

inline fun <A : Any, T : Any> <Error class: unknown class>.allFactories(tag: Any? = null): List<(A) -> T>
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
fun <T : Any> <Error class: unknown class>.AllInstances(type: TypeToken<out T>, tag: Any? = null): <Error class: unknown class><List<T>>

Gets all instances from providers that match the the given return type and tag.

fun <A, T : Any> <Error class: unknown class>.AllInstances(argType: TypeToken<in A>, type: TypeToken<T>, tag: Any? = null, arg: () -> A): <Error class: unknown class><List<T>>

Gets all instances from providers that match the the given return type and tag, curried from factories that take an argument A.

Link copied to clipboard
inline fun <T : Any> <Error class: unknown class>.allInstances(tag: Any? = null): <Error class: unknown class><List<T>>

Gets all instances from providers that match the the given return type and tag.

inline fun <T : Any> <Error class: unknown class>.allInstances(tag: Any? = null): List<T>

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

inline fun <A : Any, T : Any> <Error class: unknown class>.allInstances(tag: Any? = null, arg: A): <Error class: unknown class><List<T>>
inline fun <A, T : Any> <Error class: unknown class>.allInstances(tag: Any? = null, arg: <Error class: unknown class><A>): <Error class: unknown class><List<T>>
inline fun <A : Any, T : Any> <Error class: unknown class>.allInstances(tag: Any? = null, noinline fArg: () -> A): <Error class: unknown class><List<T>>

Gets all instances from providers that match the the given return type and tag, curried from factories that take an argument A.

inline fun <A : Any, T : Any> <Error class: unknown class>.allInstances(tag: Any? = null, arg: A): List<T>
inline fun <A, T : Any> <Error class: unknown class>.allInstances(tag: Any? = null, arg: <Error class: unknown class><A>): List<T>

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

Link copied to clipboard
fun <T : Any> <Error class: unknown class>.AllProviders(type: TypeToken<out T>, tag: Any? = null): <Error class: unknown class><List<() -> T>>

Gets all providers that match the the given return type and tag.

fun <A, T : Any> <Error class: unknown class>.AllProviders(argType: TypeToken<in A>, type: TypeToken<out T>, tag: Any? = null, arg: () -> A): <Error class: unknown class><List<() -> T>>

Gets all providers that match the the given return type and tag, curried from factories that take an argument A.

Link copied to clipboard
inline fun <T : Any> <Error class: unknown class>.allProviders(tag: Any? = null): <Error class: unknown class><List<() -> T>>

Gets all providers that match the the given return type and tag.

inline fun <T : Any> <Error class: unknown class>.allProviders(tag: Any? = null): List<() -> T>

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

inline fun <A : Any, T : Any> <Error class: unknown class>.allProviders(tag: Any? = null, arg: A): <Error class: unknown class><List<() -> T>>
inline fun <A, T : Any> <Error class: unknown class>.allProviders(tag: Any? = null, arg: <Error class: unknown class><A>): <Error class: unknown class><List<() -> T>>
inline fun <A : Any, T : Any> <Error class: unknown class>.allProviders(tag: Any? = null, noinline fArg: () -> A): <Error class: unknown class><List<() -> T>>

Gets all providers that match the the given return type and tag, curried from factories that take an argument A.

inline fun <A : Any, T : Any> <Error class: unknown class>.allProviders(tag: Any? = null, arg: A): List<() -> T>
inline fun <A, T : Any> <Error class: unknown class>.allProviders(tag: Any? = null, arg: <Error class: unknown class><A>): List<() -> T>
inline fun <A : Any, T : Any> <Error class: unknown class>.allProviders(tag: Any? = null, noinline fArg: () -> A): List<() -> T>

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

Link copied to clipboard

Creates an argument constrained spec.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bind(tag: Any? = null, overrides: Boolean? = null): DI.Builder.TypeBinder<T>

Starts the binding of a given type with a given tag.

inline fun <T : Any> DI.Builder.bind(tag: Any? = null, overrides: Boolean? = null, noinline createBinding: () -> DIBinding<*, *, T>)

Attaches a binding to the DI container

Link copied to clipboard
inline fun <A : Any, T : Any> DI.Builder.bindArgSet(tag: Any? = null, overrides: Boolean? = null)

Creates a set: multiple bindings can be added in this set.

inline fun <A : Any, T : Any> DI.Builder.bindArgSet(tag: Any? = null, overrides: Boolean? = null, noinline creator: DI.Builder.ArgSetBinder<A, T>.() -> Unit)

Creates a set and add multiple bindings to it.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bindConstant(tag: Any, overrides: Boolean? = null, creator: () -> T)

Binds a constant provider: will always return the given instance.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bindEagerSingleton(tag: Any? = null, overrides: Boolean? = null, noinline creator: DirectDI.() -> T)

Binds an eager singleton: will create an instance as soon as kodein is ready (all bindings are set) and will always return this instance.

Link copied to clipboard
inline fun <A : Any, T : Any> DI.Builder.bindFactory(tag: Any? = null, overrides: Boolean? = null, noinline creator: DirectDI.(A) -> T)

Binds a factory: each time an instance is needed, the function creator function will be called.

Link copied to clipboard
inline fun <T : Any> SearchDSL.binding(tag: Any? = null): SearchDSL.Binding

Creates a return type constrained spec.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bindInstance(tag: Any? = null, overrides: Boolean? = null, creator: () -> T)

Binds an instance provider: will always return the given instance.

Link copied to clipboard
inline fun <A : Any, T : Any> DI.Builder.bindMultiton(tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true, noinline creator: DirectDI.(A) -> T)

Binds a multiton: will create an instance on first request and will subsequently always return the same instance.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bindProvider(tag: Any? = null, overrides: Boolean? = null, noinline creator: DirectDI.() -> T)

Creates a factory: each time an instance is needed, the function creator function will be called.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bindProviderOf(noinline constructor: () -> T, tag: Any? = null, overrides: Boolean? = null)

Creates a factory: each time an instance is needed, the function constructor function will be called.

inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1> DI.Builder.bindProviderOf(noinline constructor: (P1) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2> DI.Builder.bindProviderOf(noinline constructor: (P1, P2) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2, P3> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2, P3, P4> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3, P4) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2, P3, P4, P5> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3, P4, P5) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2, P3, P4, P5, P6> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3, P4, P5, P6) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7, P8> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7, P8) -> T, tag: Any? = null, overrides: Boolean? = null)
inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7, P8, P9> DI.Builder.bindProviderOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7, P8, P9) -> T, tag: Any? = null, overrides: Boolean? = null)
Link copied to clipboard
inline fun <T : Any> DI.Builder.bindSet(tag: Any? = null, overrides: Boolean? = null)

Creates a set: multiple bindings can be added in this set.

inline fun <T : Any> DI.Builder.bindSet(tag: Any? = null, overrides: Boolean? = null, noinline creator: DI.Builder.SetBinder<T>.() -> Unit)

Creates a set and add multiple bindings to it.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bindSingleton(tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true, noinline creator: DirectDI.() -> T)

Binds a singleton: will create an instance on first request and will subsequently always return the same instance.

Link copied to clipboard
inline fun <T : Any> DI.Builder.bindSingletonOf(noinline constructor: () -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)

Binds a singleton: will create an instance on first request and will subsequently always return the same instance.

inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1> DI.Builder.bindSingletonOf(noinline constructor: (P1) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2, P3> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2, P3, P4> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3, P4) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2, P3, P4, P5> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3, P4, P5) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2, P3, P4, P5, P6> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3, P4, P5, P6) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7, P8> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7, P8) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
inline fun <T : Any, P1, P2, P3, P4, P5, P6, P7, P8, P9> DI.Builder.bindSingletonOf(noinline constructor: (P1, P2, P3, P4, P5, P6, P7, P8, P9) -> T, tag: Any? = null, overrides: Boolean? = null, sync: Boolean = true)
Link copied to clipboard
fun <T : Any> DIAware.Constant(type: TypeToken<out T>): DIProperty<T>

Gets a constant of type T and tag whose tag is the name of the receiving property.

Link copied to clipboard
inline fun <T : Any> DIAware.constant(): LazyDelegate<T>

Gets a constant of type T and tag whose tag is the name of the receiving property.

Link copied to clipboard

Creates a context constrained spec.

Link copied to clipboard

Used to define bindings with a context: bind<MyType>() with contexted<MyContext>().provider { /*...*/ }

Link copied to clipboard
inline fun <S : Any> contextFinder(noinline t: DirectDI.() -> S): ContextTranslator<Any, S>
Link copied to clipboard
inline fun <C : Any, S : Any> contextTranslator(noinline t: DirectDI.(C) -> S?): ContextTranslator<C, S>
Link copied to clipboard
inline fun <T : Any> DI.Builder.delegate(tag: Any? = null, overrides: Boolean? = null): DI.Builder.DelegateBinder<T>

Delegate the targeted type to a new binding type

Link copied to clipboard
fun BindingsMap.description(withOverrides: Boolean = false, ident: Int = 8): String

The description of all bindings in this map, using type simple display names.

Link copied to clipboard
inline fun <C : Any> diContext(context: C): DIContext<C>
inline fun <C : Any> diContext(crossinline getContext: () -> C): DIContext<C>

Defines a context and its type to be used by DI.

Link copied to clipboard
inline fun <T : Any> DI.Builder.eagerSingleton(noinline creator: NoArgBindingDI<Any>.() -> T): EagerSingleton<T>

Creates an eager singleton: will create an instance as soon as kodein is ready (all bindings are set) and will always return this instance.

Link copied to clipboard
inline fun <T : Any> erasedList(): TypeToken<List<T>>

Creates a CompositeTypeToken that defines a List<T>.

Link copied to clipboard
inline fun <K : Any, V : Any> erasedMap(): TypeToken<Map<K, V>>

Creates a CompositeTypeToken that defines a Map<K, V>.

Link copied to clipboard
inline fun <T : Any> erasedSet(): TypeToken<Set<T>>

Creates a CompositeTypeToken that defines a Set<T>.

Link copied to clipboard
fun <A, T : Any> DIAware.Factory(argType: TypeToken<in A>, type: TypeToken<out T>, tag: Any? = null): LazyDelegate<(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> Named.factory(): LazyDelegate<(A) -> T>

Gets a factory of T for the given argument type and return type. The name of the receiving property is used as tag.

inline fun <C : Any, A : Any, T : Any> DI.BindBuilder<C>.factory(noinline creator: BindingDI<C>.(A) -> T): Factory<C, A, T>

Creates a factory: each time an instance is needed, the function creator function will be called.

inline fun <A : Any, T : Any> DIAware.factory(tag: Any? = null): LazyDelegate<(A) -> T>
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
fun <A, T : Any> DIAware.FactoryOrNull(argType: TypeToken<in A>, type: TypeToken<out T>, tag: Any? = null): LazyDelegate<(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> Named.factoryOrNull(): LazyDelegate<(A) -> T?>

Gets a factory of T for the given argument type and return type, or nul if none is found. The name of the receiving property is used as tag.

inline fun <A : Any, T : Any> DIAware.factoryOrNull(tag: Any? = null): LazyDelegate<(A) -> T?>
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
fun DITree.findAllBindings(f: FindDSL.() -> Unit): List<Triple<DI.Key<*, *, *>, List<DIDefinition<*, *, *>>, ContextTranslator<*, *>?>>

Used to find bindings that match a particular SearchSpecs.

Link copied to clipboard
fun BindingsMap.fullDescription(withOverrides: Boolean = false, ident: Int = 8): String

The description of all bindings in this map, using type full display names.

Link copied to clipboard
inline fun <A : Any, T : Any> DI.hasFactory(tag: Any? = null): Boolean

Define whether a factory binding exists in the given DI container

Link copied to clipboard
inline fun <T : Any> DI.hasProvider(tag: Any? = null): Boolean

Define whether a provider binding exists in the given DI container

Link copied to clipboard
inline fun <T : Any> DI.Builder.inBindSet(tag: Any? = null, overrides: Boolean? = null, noinline creator: DI.Builder.SetBinder<T>.() -> Unit)

Add multiple bindings in an existing set

Link copied to clipboard
inline fun <T : Any> DI.Builder.inSet(tag: Any? = null, overrides: Boolean? = null, creator: () -> DIBinding<*, *, T>)

Defines that the binding will be saved in a set binding.

Link copied to clipboard
fun <T : Any> DIAware.Instance(type: TypeToken<out T>, tag: Any? = null): LazyDelegate<T>

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

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

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

Link copied to clipboard
inline fun <T : Any> Named.instance(): LazyDelegate<T>

Gets an instance of T for the given type. The name of the receiving property is used as tag.

inline fun <T : Any> DI.Builder.instance(instance: T): InstanceBinding<T>

Creates an instance provider: will always return the given instance.

inline fun <T : Any> DIAware.instance(tag: Any? = null): LazyDelegate<T>
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> Named.instance(arg: A): LazyDelegate<T>
inline fun <A : Any, T : Any> Named.instance(noinline fArg: () -> A): LazyDelegate<T>
inline fun <A, T : Any> Named.instance(arg: Typed<A>): LazyDelegate<T>

Gets an instance of T for the given type, curried from a factory that takes an argument A. The name of the receiving property is used as tag.

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

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

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
fun <T : Any> DIAware.InstanceOrNull(type: TypeToken<out T>, tag: Any? = null): LazyDelegate<T?>

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

fun <A, T : Any> DIAware.InstanceOrNull(argType: TypeToken<in A>, type: TypeToken<out T>, tag: Any? = null, arg: () -> A): LazyDelegate<T?>

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

Link copied to clipboard
inline fun <T : Any> Named.instanceOrNull(): LazyDelegate<T?>

Gets an instance of T for the given type, or null if none is found. The name of the receiving property is used as tag.

inline fun <T : Any> DIAware.instanceOrNull(tag: Any? = null): LazyDelegate<T?>
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> Named.instanceOrNull(arg: A): LazyDelegate<T?>
inline fun <A : Any, T : Any> Named.instanceOrNull(noinline fArg: () -> A): LazyDelegate<T?>
inline fun <A, T : Any> Named.instanceOrNull(arg: Typed<A>): LazyDelegate<T?>

Gets an instance of T for the given type, curried from a factory that takes an argument A, or null if none is found. The name of the receiving property is used as tag.

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

Gets an instance of T for the given type and tag, curried from a factory that takes an argument A, 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 <C : Any, A : Any, T : Any> DI.BindBuilder.WithScope<C>.multiton(ref: RefMaker? = null, sync: Boolean = true, noinline creator: BindingDI<C>.(A) -> T): Multiton<C, A, T>

Creates a multiton: will create an instance on first request for each different argument and will subsequently always return the same instance for the same argument.

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
fun <T> DIAware.newInstance(creator: DirectDI.() -> T): LazyDelegate<T>

Allows to create a new instance of an unbound object with the same API as when bounding one.

inline fun <T> DirectDIAware.newInstance(creator: DirectDI.() -> T): T

Allows the creation of a new instance with DI injection.

Link copied to clipboard
fun DIAware.On(context: DIContext<*> = this.diContext, trigger: DITrigger? = this.diTrigger): DI

Allows to create a new DI object with a context and/or a trigger set.

Link copied to clipboard
fun DIAware.on(trigger: DITrigger?): DI

Allows to create a new DI object with a trigger set.

inline fun <C : Any> DirectDIAware.on(context: C): DirectDI

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

inline fun <C : Any> DIAware.on(context: C, trigger: DITrigger? = this.diTrigger): DI
inline fun <C : Any> DIAware.on(trigger: DITrigger? = this.diTrigger, crossinline getContext: () -> C): DI

Allows to create a new DI object with a context and/or a trigger set.

Link copied to clipboard
fun <T : Any> DIAware.Provider(type: TypeToken<out T>, tag: Any? = null): LazyDelegate<() -> T>

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

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

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

Link copied to clipboard
inline fun <T : Any> Named.provider(): LazyDelegate<() -> T>

Gets a provider of T for the given type. The name of the receiving property is used as tag.

inline fun <C : Any, T : Any> DI.BindBuilder<C>.provider(noinline creator: NoArgBindingDI<C>.() -> T): Provider<C, T>

Creates a factory: each time an instance is needed, the function creator function will be called.

inline fun <T : Any> DIAware.provider(tag: Any? = null): LazyDelegate<() -> T>
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> Named.provider(arg: A): LazyDelegate<() -> T>
inline fun <A : Any, T : Any> Named.provider(noinline fArg: () -> A): LazyDelegate<() -> T>
inline fun <A : Any, T : Any> Named.provider(arg: Typed<A>): LazyDelegate<() -> T>

Gets a provider of T for the given type, curried from a factory that takes an argument A. The name of the receiving property is used as tag.

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

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

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
fun <T : Any> DIAware.ProviderOrNull(type: TypeToken<out T>, tag: Any? = null): LazyDelegate<() -> T?>

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

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

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

Link copied to clipboard
inline fun <T : Any> Named.providerOrNull(): LazyDelegate<() -> T?>

Gets a provider of T for the given type, or null if none is found. The name of the receiving property is used as tag.

inline fun <T : Any> DIAware.providerOrNull(tag: Any? = null): LazyDelegate<() -> T?>
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> Named.providerOrNull(arg: A): LazyDelegate<() -> T?>
inline fun <A : Any, T : Any> Named.providerOrNull(noinline fArg: () -> A): LazyDelegate<() -> T?>
inline fun <A, T : Any> Named.providerOrNull(arg: Typed<A>): LazyDelegate<() -> T?>

Gets a provider of T for the given type, curried from a factory that takes an argument A, or null if none is found. The name of the receiving property is used as tag.

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

Gets a provider of T for the given type and tag, curried from a factory that takes an argument A, 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.

Link copied to clipboard
inline fun <S : Any> DI.Builder.registerContextFinder(noinline t: DirectDI.() -> S)
Link copied to clipboard
inline fun <C : Any, S : Any> DI.Builder.registerContextTranslator(noinline t: DirectDI.(C) -> S?)
Link copied to clipboard

Used to define bindings with a scope: bind<MyType>() with scoped(myScope).singleton { /*...*/ }

Link copied to clipboard
inline fun <C : Any, T : Any> DI.BindBuilder.WithScope<C>.singleton(ref: RefMaker? = null, sync: Boolean = true, noinline creator: NoArgBindingDI<C>.() -> T): Singleton<C, T>

Creates a singleton: will create an instance on first request and will subsequently always return the same instance.

Link copied to clipboard
inline fun subDI(parentDI: DI, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit): LazyDI

Allow to create an extended version of a given DI container

Link copied to clipboard
inline fun <A, T : Any> (A) -> T.toProvider(crossinline arg: () -> A): () -> T

Transforms a factory function into a provider function by currying the factory with the given argument.

Link copied to clipboard
infix inline fun <C : Any, A : Any, T : Any> TypeBinderSubTypes<T>.with(noinline block: (TypeToken<out T>) -> <Error class: unknown class><in C, in A, out T>)

Allows to define a binding that will be called for any subtype of this type.

infix inline fun <T : Any> DI.Builder.ConstantBinder.with(value: T)

Binds the previously given tag to the given instance.