Scope

class Scope(val scopeQualifier: Qualifier, val id: ScopeID, val isRoot: Boolean = false, val scopeArchetype: TypeQualifier? = null, _koin: Koin) : Lockable

Constructors

Link copied to clipboard
constructor(scopeQualifier: Qualifier, id: ScopeID, isRoot: Boolean = false, scopeArchetype: TypeQualifier? = null, _koin: Koin)

Properties

Link copied to clipboard
Link copied to clipboard
val id: ScopeID
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun close()

Close all instances from this scope

Link copied to clipboard
inline fun <T> declare(instance: T, qualifier: Qualifier? = null, secondaryTypes: List<KClass<*>> = emptyList(), allowOverride: Boolean = true, holdInstance: Boolean = false)

Declare an instance definition for the current scope using the given object.

Link copied to clipboard
inline fun <T : Any> get(qualifier: Qualifier? = null, noinline parameters: ParametersDefinition? = null): T
fun <T> get(clazz: KClass<*>, qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): T

Get a Koin instance

Link copied to clipboard
fun <T : Any> Scope.get(clazz: Class<*>, qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): T

Get a Koin instance

Link copied to clipboard
inline fun <T : Any> 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)

Link copied to clipboard
fun getKoin(): Koin

Get current Koin instance

Link copied to clipboard
Link copied to clipboard
inline fun <T : Any> getOrNull(qualifier: Qualifier? = null, noinline parameters: ParametersDefinition? = null): T?
fun <T> getOrNull(clazz: KClass<*>, qualifier: Qualifier? = null, parameters: ParametersDefinition? = null): T?

Get a Koin instance if available

Link copied to clipboard
fun <T : Any> getProperty(key: String): T
fun <T : Any> getProperty(key: String, defaultValue: T): T

Retrieve a property

Link copied to clipboard
fun <T : Any> getPropertyOrNull(key: String): T?

Retrieve a property

Link copied to clipboard
fun getScope(scopeID: ScopeID): Scope

Get Scope

Link copied to clipboard
inline fun <T : Any> getSource(): T?

Get Koin Scope "source" instance. Retrive the object instance, that initiated the creation of the scope.

Link copied to clipboard
fun <T> getWithParameters(clazz: KClass<*>, qualifier: Qualifier? = null, parameters: ParametersHolder? = null): T
Link copied to clipboard
inline fun <T : Any> inject(qualifier: Qualifier? = null, mode: LazyThreadSafetyMode = LazyThreadSafetyMode.SYNCHRONIZED, noinline parameters: ParametersDefinition? = null): Lazy<T>

Lazy inject a Koin instance

Link copied to clipboard
inline fun <T : Any> injectOrNull(qualifier: Qualifier? = null, mode: LazyThreadSafetyMode = LazyThreadSafetyMode.SYNCHRONIZED, noinline parameters: ParametersDefinition? = null): Lazy<T?>

Lazy inject a Koin instance if available

Link copied to clipboard
inline fun isNotClosed(): Boolean
Link copied to clipboard
fun linkTo(vararg scopes: Scope)

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

Link copied to clipboard
inline fun <R> Scope.new(constructor: () -> R): R

Auto resolve a class dependencies by using its constructor reference. The resolution is done at compile time by leveraging inline functions, no reflection is required.

inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) -> R): R
inline fun <R, T1> Scope.new(constructor: (T1) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) -> R): R
inline fun <R, T1, T2> Scope.new(constructor: (T1, T2) -> R): R
inline fun <R, T1, T2, T3> Scope.new(constructor: (T1, T2, T3) -> R): R
inline fun <R, T1, T2, T3, T4> Scope.new(constructor: (T1, T2, T3, T4) -> R): R
inline fun <R, T1, T2, T3, T4, T5> Scope.new(constructor: (T1, T2, T3, T4, T5) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6> Scope.new(constructor: (T1, T2, T3, T4, T5, T6) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8) -> R): R
inline fun <R, T1, T2, T3, T4, T5, T6, T7, T8, T9> Scope.new(constructor: (T1, T2, T3, T4, T5, T6, T7, T8, T9) -> R): R
Link copied to clipboard

Register a callback for this Scope Instance

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun unlink(vararg scopes: Scope)

Remove linked scope