Package org.kodein.di.bindings

Types

ArgSetBinding
Link copied to clipboard
common
class ArgSetBinding<C : Any, A, T : Any>(contextType: TypeToken<in C>, argType: TypeToken<in A>, _elementType: TypeToken<out T>, createdType: TypeToken<out Set<T>>) : BaseMultiBinding<C, A, T>
Binding that holds multiple factory bindings (e.g.
BaseMultiBinding
Link copied to clipboard
common
abstract class BaseMultiBinding<C : Any, A, T : Any> : DIBinding<C, A, Set<T>>
Base class for binding set.
Binding
Link copied to clipboard
common
interface Binding<C : Any, A, T : Any>
Base class that knows how to get an instance.
BindingDI
Link copied to clipboard
common
interface BindingDI<out C : Any> : DirectDI, WithContext<C>
Direct DI interface to be passed to factory methods that hold references.
ContextTranslator
Link copied to clipboard
common
interface ContextTranslator<in C : Any, S : Any>
DIBinding
Link copied to clipboard
common
interface DIBinding<C : Any, A, T : Any> : Binding<C, A, T>
Binding that is registered inside a DI object.
EagerSingleton
Link copied to clipboard
common
class EagerSingleton<T : Any>(builder: DIContainer.Builder, createdType: TypeToken<out T>, creator: NoArgBindingDI<Any>.() -> T) : NoArgDIBinding<Any, T>
Concrete eager singleton: will create an instance as soon as di is ready (all bindings are set) and will always return this instance.
ErasedContext
Link copied to clipboard
common
object ErasedContext : DIContext<ErasedContext>
ExternalSource
Link copied to clipboard
common
interface ExternalSource
An external source can provide to an answer to a retrieval that do not correspond to any binding that is registered in DI.
Factory
Link copied to clipboard
common
class Factory<C : Any, A, T : Any>(contextType: TypeToken<in C>, argType: TypeToken<in A>, createdType: TypeToken<out T>, creator: BindingDI<C>.(A) -> T) : DIBinding<C, A, T>
Concrete factory: each time an instance is needed, the function creator function will be called.
InstanceBinding
Link copied to clipboard
common
class InstanceBinding<T : Any>(createdType: TypeToken<out T>, instance: T) : NoArgDIBinding<Any, T>
Concrete instance provider: will always return the given instance.
Multiton
Link copied to clipboard
common
class Multiton<C : Any, A, T : Any>(scope: Scope<C>, contextType: TypeToken<in C>, explicitContext: Boolean, argType: TypeToken<in A>, createdType: TypeToken<out T>, refMaker: RefMaker?, sync: Boolean, creator: BindingDI<C>.(A) -> T) : DIBinding<C, A, T>
Concrete multiton: will create one and only one instance for each argument.
NoArgBindingDI
Link copied to clipboard
common
interface NoArgBindingDI<out C : Any> : DirectDI, WithContext<C>
Direct DI interface to be passed to provider methods that hold references.
NoArgDIBinding
Link copied to clipboard
common
interface NoArgDIBinding<C : Any, T : Any> : DIBinding<C, Unit, T>
DIBinding specialization that has no argument.
NoScope
Link copied to clipboard
common
class NoScope : Scope<Any?>
Default Scope: will always return the same registry, no matter the context.
Provider
Link copied to clipboard
common
class Provider<C : Any, T : Any>(contextType: TypeToken<in C>, createdType: TypeToken<out T>, creator: NoArgBindingDI<C>.() -> T) : NoArgDIBinding<C, T>
Concrete provider: each time an instance is needed, the function creator function will be called.
Reference
Link copied to clipboard
common
data class Reference<out T : Any>(current: T, next: () -> T?)
A reference gives a data and a function to later check the validity and retrieve that data.
RefMaker
Link copied to clipboard
common
interface RefMaker
A Function that creates a reference.
Scope
Link copied to clipboard
common
interface Scope<in C>
A scope is an object that can return (or create) a ScopeRegistry according to a context.
ScopeCloseable
Link copied to clipboard
common
interface ScopeCloseable
ScopeRegistry
Link copied to clipboard
common
sealed class ScopeRegistry : ScopeCloseable
A registry is responsible managing references inside a scope.
SetBinding
Link copied to clipboard
common
class SetBinding<C : Any, T : Any>(contextType: TypeToken<in C>, _elementType: TypeToken<out T>, createdType: TypeToken<out Set<T>>) : BaseMultiBinding<C, Unit, T> , NoArgDIBinding<C, Set<T>>
Binding that holds multiple factory bindings (e.g.
SimpleAutoContextTranslator
Link copied to clipboard
common
class SimpleAutoContextTranslator<S : Any>(scopeType: TypeToken<in S>, t: DirectDI.() -> S) : ContextTranslator<Any, S>
SimpleContextTranslator
Link copied to clipboard
common
class SimpleContextTranslator<in C : Any, S : Any>(contextType: TypeToken<in C>, scopeType: TypeToken<in S>, t: DirectDI.(C) -> S?) : ContextTranslator<C, S>
SingleItemScopeRegistry
Link copied to clipboard
common
class SingleItemScopeRegistry : ScopeRegistry
ScopeRegistry that is specialized to hold only one item.
Singleton
Link copied to clipboard
common
class Singleton<C : Any, T : Any>(scope: Scope<C>, contextType: TypeToken<in C>, explicitContext: Boolean, createdType: TypeToken<out T>, refMaker: RefMaker?, sync: Boolean, creator: NoArgBindingDI<C>.() -> T) : NoArgDIBinding<C, T>
Singleton Binding: will create an instance on first request and will subsequently always return the same instance.
SingletonReference
Link copied to clipboard
common
object SingletonReference : RefMaker
A reference that acts as a Singleton: calls a creator function the first time, and then always return the same instance.
StandardScopeRegistry
Link copied to clipboard
common
class StandardScopeRegistry : ScopeRegistry
Standard ScopeRegistry implementation.
SubScope
Link copied to clipboard
common
abstract class SubScope<C, PC>(parentScope: Scope<PC>) : Scope<C>
SubTypes
Link copied to clipboard
class SubTypes<C : Any, A, T : Any>(contextType: TypeToken<in C>, argType: TypeToken<in A>, createdType: TypeToken<out T>, block: (TypeToken<out T>) -> DIBinding<in C, in A, out T>) : DIBinding<C, A, T>
Binding that holds multiple bindings for subtypes of T.
TypeBinderInSet
Link copied to clipboard
common
class TypeBinderInSet<in T : Any, S : Any>
Second part of the bind<Type>().inSet() with binding syntax.
TypeBinderSubTypes
Link copied to clipboard
class TypeBinderSubTypes<T : Any>
Second part of the bind<Type>().inSet() with binding syntax.
UnboundedScope
Link copied to clipboard
common
open class UnboundedScope(registry: ScopeRegistry) : Scope<Any?> , ScopeCloseable
Scope that is not bound to a context (always lives).
WeakContextScope
Link copied to clipboard
open class WeakContextScope<in C>(newRepo: () -> ScopeRegistry) : Scope<C>
Scope that map scope registries associated to weak contexts.
WithContext
Link copied to clipboard
common
interface WithContext<out C : Any>
Indicates that the context of a retrieval is accessible.

Functions

externalFactory
Link copied to clipboard
common
fun externalFactory(f: (Any?) -> Any): (Any?) -> Any
Simple function that types a lambda as a factory function that can be used as the return in the implementation of ExternalSource.getFactory.
InSet
Link copied to clipboard
common
fun <T : Any> DI.Builder.TypeBinder<T>.InSet(setTypeToken: TypeToken<Set<T>>): TypeBinderInSet<T, Set<T>>
Allows to bind in an existing set binding (rather than directly as a new binding).
subTypes
Link copied to clipboard
fun <T : Any> DI.Builder.TypeBinder<T>.subTypes(): TypeBinderSubTypes<T>
Allows to bind in an existing set binding (rather than directly as a new binding).
toKContext
Link copied to clipboard
common
fun <C : Any, S : Any> ContextTranslator<C, S>.toKContext(di: DirectDI, ctx: C): DIContext<S>?