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

Scope

data class Scope

Constructors

<init>

Scope(id: ScopeID, _scopeDefinition: ScopeDefinition, _koin: Koin)

Properties

_scopeDefinition

val _scopeDefinition: ScopeDefinition

closed

val closed: Boolean

id

val id: ScopeID

logger

val logger: Logger

Functions

addParameters

fun addParameters(parameters: DefinitionParameters): Unit

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?): S

clearParameters

fun clearParameters(): Unit

close

Close all instances from this scope

fun close(): Unit

declare

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 the current scope is root)

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

dropInstance

fun dropInstance(beanDefinition: BeanDefinition<*>): 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
fun <T : Any> get(clazz: Class<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>

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

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

getKoin

Get current Koin instance

fun getKoin(): Koin

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 getProperty(key: String, defaultValue: String): String
fun getProperty(key: String): String

getPropertyOrNull

Retrieve a property

fun getPropertyOrNull(key: String): String?

getScope

Get Scope

fun getScope(scopeID: ScopeID): Scope

getSource

fun <T : Any> getSource(): T

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?>

linkTo

Add parent Scopes to allow instance resolution i.e: linkTo(scopeC) - allow to resolve instance to current scope and scopeC

fun linkTo(vararg scopes: Scope): Unit

loadDefinition

fun loadDefinition(beanDefinition: BeanDefinition<*>): Unit

registerCallback

Register a callback for this Scope Instance

fun registerCallback(callback: ScopeCallback): Unit

setSource

fun setSource(t: Any?): Unit

toString

fun toString(): String

unlink

Remove linked scope

fun unlink(vararg scopes: Scope): Unit