DefaultScope

class DefaultScope(val qualifier: Qualifier, val parent: DefaultScope? = null) : Scope

Constructors

Link copied to clipboard
constructor(qualifier: Qualifier, parent: DefaultScope? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun closeAll()

Closes this scope and clears all of its cached singleton instances. This is typically called when the lifecycle associated with this scope ends (e.g., Activity.onDestroy()). Note: This does not close parent or child scopes.

Link copied to clipboard
open override fun declare(qualifier: Qualifier, instance: Any)

Manually declares and adds a pre-existing instance to this scope's cache. This is useful for binding instances that are not created by the DI framework itself, such as Android's Context.

Link copied to clipboard
open override fun get(qualifier: Qualifier): Any

Resolves and returns a dependency instance that matches the given qualifier. If the instance is a singleton and already created, it returns the cached instance. If it's a factory, a new instance is created on each call. If the instance is not found in the current scope, it will search in the parent scope.

Link copied to clipboard
@JvmName(name = "inlineGet")
inline fun <T : Any> DefaultScope.get(qualifier: Qualifier = TypeQualifier(T::class), noinline pathBuilder: ScopePathBuilder.() -> Path = { Path() }): Any
Link copied to clipboard
open override fun getSubScope(qualifier: Qualifier): DefaultScope

Retrieves a direct child scope identified by the given qualifier.

Link copied to clipboard
open override fun registerFactory(vararg modules: DependencyModule)

Registers one or more DependencyModules into the scope. This populates the scope with the necessary factories to create dependency instances.

Link copied to clipboard
open override fun resolvePath(path: Path): DefaultScope

Navigates through the scope hierarchy and returns a descendant scope specified by the path. The path is resolved from the current scope downwards.

Link copied to clipboard