InjectionScope

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.

Inheritors

Functions

Link copied to clipboard

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

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

inline operator fun <T : Any> MetalessInjectionScope.invoke(qualifier: Qualifier = EmptyQualifier): ReadOnlyProperty<Any?, T>

Create an injector for the given class, turned to an identifier, and an optional qualifier. See InjectionScope.inject for more information.

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).

Link copied to clipboard
inline fun <T : Any> MetalessInjectionScope.optional(qualifier: Qualifier = EmptyQualifier): ReadOnlyProperty<Any?, T?>

Create an injector for the given class and optional qualifier. If such an identifier cannot be found within the environment, returns null (unlike other functions which throw a ComponentNotFoundException).

Properties

Link copied to clipboard

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