Builder

interface Builder : DI.BindBuilder<Any> , DI.BindBuilder.WithScope<Any>

Allows for the DSL inside the block argument of the constructor of DI and DI.Module.

Methods of this classes are really just proxies to the DIContainer.Builder methods.

Types

Link copied to clipboard
interface ConstantBinder

Left part of the constant-binding syntax (constant(tag)).

Link copied to clipboard
abstract class DelegateBinder<T : Any>

Left part of the delegate-binding syntax (delegate(tag)).

Link copied to clipboard
interface DirectBinder

Left part of the direct-binding syntax (bind(tag)).

Link copied to clipboard
interface TypeBinder<T : Any>

Left part of the type-binding syntax (bind(type, tag)).

Functions

Link copied to clipboard
abstract fun Bind(tag: Any? = null, overrides: Boolean? = null): DI.Builder.DirectBinder

Starts a direct binding with a given tag. A direct bind does not define the type to be bound, the type will be defined according to the bound factory.

abstract fun <T : Any> Bind(    tag: Any? = null,     overrides: Boolean? = null,     binding: DIBinding<*, *, T>)

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

abstract fun <T : Any> Bind(    type: TypeToken<out T>,     tag: Any? = null,     overrides: Boolean? = null): DI.Builder.TypeBinder<T>

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

Link copied to clipboard
abstract fun <T : Any> BindSet(    tag: Any? = null,     overrides: Boolean? = null,     binding: DIBinding<*, *, T>)

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

Link copied to clipboard
abstract fun constant(tag: Any, overrides: Boolean? = null): DI.Builder.ConstantBinder

Starts a constant binding.

Link copied to clipboard
abstract fun <T : Any> Delegate(    type: TypeToken<out T>,     tag: Any? = null,     overrides: Boolean? = null): DI.Builder.DelegateBinder<T>

Create a delegate binding to a given bound type with a given tag.

Link copied to clipboard
abstract fun import(module: DI.Module, allowOverride: Boolean = false)

Imports all bindings defined in the given DI.Module into this builder's definition.

Link copied to clipboard
abstract fun importAll(vararg modules: DI.Module, allowOverride: Boolean = false)
abstract fun importAll(modules: Iterable<DI.Module>, allowOverride: Boolean = false)

Imports all bindings defined in the given DI.Modules into this builder's definition.

Link copied to clipboard
abstract fun importOnce(module: DI.Module, allowOverride: Boolean = false)

Like import but checks that will only import each module once.

Link copied to clipboard
abstract fun onReady(cb: DirectDI.() -> Unit)

Adds a callback that will be called once the DI object is configured and instantiated.

Link copied to clipboard
abstract fun RegisterContextTranslator(translator: ContextTranslator<*, *>)

Properties

Link copied to clipboard
abstract val containerBuilder: DIContainer.Builder

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

Link copied to clipboard
abstract val contextType: TypeToken<Any>

The context type that will be used by all bindings that are defined in this DSL context.

Link copied to clipboard
abstract val explicitContext: Boolean
Link copied to clipboard
abstract val scope: Scope<Any>

The scope that will be used by all bindings that are defined in this DSL context.

Inheritors

Link copied to clipboard

Extensions

Link copied to clipboard
inline fun <A : Any, T : Any> DI.Builder.argSetBinding(): ArgSetBinding<Any, A, T>

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

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

Attaches a binding to the DI container

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.

fun DI.Builder.bind(tag: Any? = null, overrides: Boolean? = null): DI.Builder.DirectBinder

Starts a direct binding with a given tag. A direct bind does not define the type to be bound, the type will be defined according to the bound factory.

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.

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> 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.bindSet(tag: Any? = null, overrides: Boolean? = null)

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

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 <C : Any> DI.Builder.contexted(): DI.BindBuilder<C>

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

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
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> 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
inline fun <T : Any> DI.Builder.instance(instance: T): InstanceBinding<T>

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

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
inline fun <C : Any> DI.Builder.scoped(scope: Scope<C>): DI.BindBuilder.WithScope<C>

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

Link copied to clipboard
inline fun <T : Any> DI.Builder.setBinding(): SetBinding<Any, T>

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