DependencyResolver

interface DependencyResolver : MutableDependencyMap, CoroutineScope(source)

Extends DependencyMap with reflection, allowing for the automatic injection of types.

Report a problem

Inheritors

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
abstract fun contains(key: DependencyKey): Boolean

Checks if the given dependency key is present in the dependency map.

Link copied to clipboard
inline suspend fun <T : Any> DependencyResolver.create(): T

Creates an instance of the specified type T using the dependency resolver. This function uses the DependencyReflection mechanism to dynamically construct an instance of the requested type, resolving dependencies as needed.

inline suspend fun <T : Any> DependencyResolver.create(kClass: KClass<out T>): T

Creates or retrieves an instance of the specified type T from the DependencyResolver. If the instance does not already exist, it is created using reflection.

Link copied to clipboard
open suspend fun <T> get(key: DependencyKey): T

Retrieves an instance of the dependency associated with the given key from the dependency map.

Link copied to clipboard

Get an item from the dependency map synchronously.

Blocking is unavailable for other platforms, so we instead attempt to get the completed value.

Link copied to clipboard
open fun <T> getDeferred(key: DependencyKey): Deferred<T>
Link copied to clipboard
Link copied to clipboard
abstract suspend fun <T> getOrPut(key: DependencyKey, defaultValue: suspend () -> T): T

Retrieves the value associated with the specified key if it exists. If the key does not already have an associated value, the result of invoking the defaultValue function will be stored and returned as the value for the given key.

Link copied to clipboard

Decorates the dependency resolver with a qualified name for the expected type.

Link copied to clipboard

Combines two DependencyMaps into one.

Link copied to clipboard
inline suspend fun <T> DependencyResolver.resolve(key: String? = null): T

Get the dependency from the map for the key represented by the type (and optionally, with the given name).