koin-core / org.koin.core / Koin

Koin

class Koin

Koin

Gather main features to use on Koin context

Author
Arnaud Giuliani

Constructors

<init>

Koin

Koin()

Properties

logger

var logger: Logger

propertyRegistry

val propertyRegistry: PropertyRegistry

scopeRegistry

val scopeRegistry: ScopeRegistry

Functions

bind

Get instance of primary type P and secondary type S (not for scoped instances)

fun <S, P> bind(parameters: ParametersDefinition? = null): S
fun <S> bind(primaryType: KClass<*>, secondaryType: KClass<*>, parameters: ParametersDefinition? = null): S

close

Close all resources from context

fun close(): Unit

createScope

Create a Scope instance

fun createScope(scopeId: ScopeID, qualifier: Qualifier, source: Any? = null): Scope
fun <T : Any> createScope(scopeId: ScopeID, source: Any? = null): Scope
fun <T : Any> createScope(scopeId: ScopeID = UUID.randomUUID().toString()): Scope
fun <T : KoinScopeComponent> createScope(t: T): Scope

declare

Declare a component definition from the given instance This result of declaring a single definition of type T, returning the given instance

fun <T : Any> declare(instance: T, qualifier: Qualifier? = null, secondaryTypes: List<KClass<*>> = emptyList(), override: Boolean = false): Unit

deleteProperty

Delete a property

fun deleteProperty(key: String): Unit

deleteScope

Delete a scope instance

fun deleteScope(scopeId: ScopeID): Unit

get

Get a Koin instance

fun <T : Any> get(qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): T
fun <T : Any> get(clazz: KClass<T>, qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): T

getAll

Get a all instance for given inferred class (in primary or secondary type)

fun <T : Any> getAll(): List<T>

getOrCreateScope

Get or Create a Scope instance

fun getOrCreateScope(scopeId: ScopeID, qualifier: Qualifier, source: Any? = null): Scope
fun <T : Any> getOrCreateScope(scopeId: ScopeID): Scope

getOrNull

Get a Koin instance if available

fun <T : Any> getOrNull(qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): T?
fun <T : Any> getOrNull(clazz: KClass<T>, qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): T?

getProperty

Retrieve a property

fun <T : Any> getProperty(key: String, defaultValue: T): T
fun <T : Any> getProperty(key: String): T?

getScope

get a scope instance

fun getScope(scopeId: ScopeID): Scope

getScopeOrNull

get a scope instance

fun getScopeOrNull(scopeId: ScopeID): Scope?

inject

Lazy inject a Koin instance

fun <T : Any> inject(qualifier: Qualifier? = null, mode: LazyThreadSafetyMode = LazyThreadSafetyMode.SYNCHRONIZED, parameters: ParametersDefinition? = null): Lazy<T>

injectOrNull

Lazy inject a Koin instance if available

fun <T : Any> injectOrNull(qualifier: Qualifier? = null, mode: LazyThreadSafetyMode = LazyThreadSafetyMode.SYNCHRONIZED, parameters: ParametersDefinition? = null): Lazy<T?>

loadModules

fun loadModules(modules: List<Module>, createEagerInstances: Boolean = false): Unit

setProperty

Save a property

fun setProperty(key: String, value: Any): Unit

setupLogger

fun setupLogger(logger: Logger): Unit

unloadModules

fun unloadModules(modules: List<Module>, createEagerInstances: Boolean = false): Unit