UnsafeMutableEnvironment

A fully mutable extensible environment implementation with very little safety.

This class should not be used in main code and only within test code that typically requires more flexibility and the ability to add elements on the fly.

You should use the class within a TegralDiBaseTest, although it is not a requirement.

Mutability

You can mutate this environment (i.e. add components) by using any put function you are already used to. You can put components and modules.

You can also mutate this environment's meta-environment, either by:

Characteristics

  • Eager object creation. Objects are created upon construction of this environment.

  • Active object injection. Objects are re-injected at every use.

  • NI/Mutable. Objects can be replaced, injection methods will not always return the same thing.<

Constructors

Link copied to clipboard
fun UnsafeMutableEnvironment(baseContext: ExtensibleEnvironmentContext)

Types

Link copied to clipboard
Link copied to clipboard
object Meta : InjectionEnvironmentKind<Nothing>

Dummy environment kind for use with UnsafeMutableEnvironment.

Link copied to clipboard

A simple, mutable environment that can also dispatch requests for a meta-environment to the one passed as a constructor parameter.

Functions

Link copied to clipboard
open override fun <T : Any> createInjector(identifier: Identifier<T>, onInjection: (T) -> Unit): Injector<T>
Link copied to clipboard
open fun <T : Any> get(identifier: Identifier<T>): T
Link copied to clipboard
open override fun getAllIdentifiers(): Sequence<Identifier<*>>
Link copied to clipboard
open override fun <T : Any> getOrNull(identifier: Identifier<T>): T?
Link copied to clipboard
open override fun <T : Any> getResolverOrNull(identifier: Identifier<T>): IdentifierResolver<T>?
Link copied to clipboard
open override fun meta(action: ContextBuilderDsl.() -> Unit)
Link copied to clipboard
open override fun <T : Any> put(declaration: Declaration<T>)

Properties

Link copied to clipboard
open override val components: EnvironmentComponents

The components that have been registered in this environment.

Link copied to clipboard
open override val metaEnvironment: UnsafeMutableEnvironment.MutableEnvironment