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

propertyRegistry

val propertyRegistry: PropertyRegistry

rootScope

val rootScope: Scope

scopeRegistry

val scopeRegistry: ScopeRegistry

Functions

bind

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

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

close

fun close(): Unit

Close all resources from context

createScope

fun createScope(scopeId: ScopeID, qualifier: Qualifier): Scope

Create a Scope instance

declare

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

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

deleteScope

fun deleteScope(scopeId: ScopeID): Unit

Delete a scope instance

get

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

Get a Koin instance

getAll

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

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

getOrCreateScope

fun getOrCreateScope(scopeId: ScopeID, qualifier: Qualifier): Scope

Get or Create a Scope instance

getOrNull

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

Get a Koin instance if available

getProperty

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

Retrieve a property

getScope

fun getScope(scopeId: ScopeID): Scope

get a scope instance

getScopeOrNull

fun getScopeOrNull(scopeId: ScopeID): Scope?

get a scope instance

inject

fun <T> inject(qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): Lazy<T>

Lazy inject a Koin instance

injectOrNull

fun <T> injectOrNull(qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): Lazy<T?>

Lazy inject a Koin instance if available

setProperty

fun <T : Any> setProperty(key: String, value: T): Unit

Save a property