InjectionScope

interface InjectionScope : MetalessInjectionScope

An injection scope provides an entrypoint for components to retrieve the dependencies they need.

This should be passed as a constructor parameter to components that require injection. Use the InjectionScope.invoke operator to retrieve dependencies.

Functions

Link copied to clipboard
abstract fun <T : Any> inject(what: Identifier<T>): Injector<T>

Create an injector for the given identifier. The behavior of the injection depends on the injection environment, but this is guaranteed to return an element of type T.

Link copied to clipboard
open fun <T : Any> optional(what: Identifier<T>): Injector<T?>

Create an injector for the given identifier. If such an identifier cannot be found within the environment, returns null (unlike inject which throws a ComponentNotFoundException).

Properties

Link copied to clipboard
abstract val meta: MetalessInjectionScope

Returns another injection scope that provides access to the components in the meta-environment.

Inheritors

Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard
inline fun <R : Any, T : Any> InjectionScope.factory(): ReadOnlyProperty<R, T>

DSL for injecting factory-made objects. Usage is factory from scope.

Link copied to clipboard
operator fun <T : Any> InjectionScope.invoke(identifier: Identifier<T>): ReadOnlyProperty<Any?, T>

Create an injector for the given identifier. See InjectionScope.inject for more information.