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

ConstantBinder
Link copied to clipboard
common
interface ConstantBinder
Left part of the constant-binding syntax (constant(tag)).
DirectBinder
Link copied to clipboard
common
interface DirectBinder
Left part of the direct-binding syntax (bind(tag)).
TypeBinder
Link copied to clipboard
common
interface TypeBinder<T : Any>
Left part of the type-binding syntax (bind(type, tag)).

Functions

Bind
Link copied to clipboard
common
abstract fun Bind(tag: Any? = null, overrides: Boolean? = null): DI.Builder.DirectBinder
Starts a direct binding with a given tag.
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.
BindSet
Link copied to clipboard
common
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.
constant
Link copied to clipboard
common
abstract fun constant(tag: Any, overrides: Boolean? = null): DI.Builder.ConstantBinder
Starts a constant binding.
import
Link copied to clipboard
common
abstract fun import(module: DI.Module, allowOverride: Boolean = false)
Imports all bindings defined in the given DI.Module into this builder's definition.
importAll
Link copied to clipboard
common
abstract fun importAll(vararg modules: DI.Module, allowOverride: Boolean = false)
Imports all bindings defined in the given DI.Modules into this builder's definition.
abstract fun importAll(modules: Iterable<DI.Module>, allowOverride: Boolean = false)
Imports all bindings defined in the given DI.Modules into this builder's definition.
importOnce
Link copied to clipboard
common
abstract fun importOnce(module: DI.Module, allowOverride: Boolean = false)
Like import but checks that will only import each module once.
onReady
Link copied to clipboard
common
abstract fun onReady(cb: DirectDI.() -> Unit)
Adds a callback that will be called once the DI object is configured and instantiated.
RegisterContextTranslator
Link copied to clipboard
common
abstract fun RegisterContextTranslator(translator: ContextTranslator<*, *>)

Properties

containerBuilder
Link copied to clipboard
common
abstract val containerBuilder: DIContainer.Builder
Every methods eventually ends up to a call to this builder.
contextType
Link copied to clipboard
common
abstract val contextType: TypeToken<Any>
The context type that will be used by all bindings that are defined in this DSL context.
explicitContext
Link copied to clipboard
common
abstract val explicitContext: Boolean
scope
Link copied to clipboard
common
abstract val scope: Scope<Any>
The scope that will be used by all bindings that are defined in this DSL context.

Inheritors

DI
Link copied to clipboard

Extensions

argSetBinding
Link copied to clipboard
common
inline fun <A : Any, T : Any> DI.Builder.argSetBinding(): ArgSetBinding<Any, A, T>
Creates a set: multiple bindings can be added in this set.
bind
Link copied to clipboard
common
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.
bindArgSet
Link copied to clipboard
common
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.
bindConstant
Link copied to clipboard
common
inline fun <T : Any> DI.Builder.bindConstant(tag: Any, overrides: Boolean? = null, creator: () -> T)
Binds a constant provider: will always return the given instance.
bindEagerSingleton
Link copied to clipboard
common
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.
bindFactory
Link copied to clipboard
common
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.
bindInstance
Link copied to clipboard
common
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.
bindMultiton
Link copied to clipboard
common
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.
bindProvider
Link copied to clipboard
common
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.
bindSet
Link copied to clipboard
common
inline fun <T : Any> DI.Builder.bindSet(tag: Any? = null, overrides: Boolean? = null)
Creates a set: multiple bindings can be added in this set.
bindSingleton
Link copied to clipboard
common
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.
contexted
Link copied to clipboard
common
inline fun <C : Any> DI.Builder.contexted(): DI.BindBuilder<C>
Used to define bindings with a context: bind<MyType>() with contexted<MyContext>().provider { /*...*/ }
eagerSingleton
Link copied to clipboard
common
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.
inSet
Link copied to clipboard
common
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.
instance
Link copied to clipboard
common
inline fun <T : Any> DI.Builder.instance(instance: T): InstanceBinding<T>
Creates an instance provider: will always return the given instance.
registerContextFinder
Link copied to clipboard
common
inline fun <S : Any> DI.Builder.registerContextFinder(noinline t: DirectDI.() -> S)
registerContextTranslator
Link copied to clipboard
common
inline fun <C : Any, S : Any> DI.Builder.registerContextTranslator(noinline t: DirectDI.(C) -> S?)
scoped
Link copied to clipboard
common
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 { /*...*/ }
setBinding
Link copied to clipboard
common
inline fun <T : Any> DI.Builder.setBinding(): SetBinding<Any, T>
Creates a set: multiple bindings can be added in this set.