koin-core / org.koin.core.scope / Scope

Scope

data class Scope

Constructors

<init>

Scope(id: ScopeID, isRoot: Boolean = false, _koin: Koin)

Properties

beanRegistry

val beanRegistry: BeanRegistry

id

val id: ScopeID

isRoot

val isRoot: Boolean

set

var set: ScopeDefinition?

Functions

bind

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

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

close

fun close(): Unit

Close all instances from this scope

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 scoped/single definition of type T, returning the given instance (single definition of th current scope is root)

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)

fun <T> getAll(clazz: KClass<*>): List<T>

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

getKoin

fun getKoin(): Koin

Get current Koin 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

getPropertyOrNull

fun <T> getPropertyOrNull(key: String): T?

Retrieve a property

getScope

fun getScope(scopeID: ScopeID): Scope

Get Scope

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

registerCallback

fun registerCallback(callback: ScopeCallback): Unit

Register a callback for this Scope Instance

toString

fun toString(): String