AbstractModuleBuilder

abstract class AbstractModuleBuilder

An abstract base class for creating a DependencyModule using a DSL. It provides the core functions for defining dependencies, such as single, factory, and scope. This class is not meant to be used directly but should be extended by concrete builder implementations.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

A mutable list that collects all the DependencyFactory instances created by the builder.

Link copied to clipboard
abstract val scope: Scope

The current Scope in which the dependencies are being defined.

Functions

Link copied to clipboard
fun <T : AbstractModuleBuilder> baseScope(qualifier: Qualifier, builderGenerator: DefaultScope.() -> T, block: T.() -> Unit)

An internal-use function to create and register a sub-scope factory.

Link copied to clipboard

Builds and returns the DependencyModule containing all the defined factories.

Link copied to clipboard
inline fun <T : Any> factory(qualifier: Qualifier = TypeQualifier(T::class), noinline create: () -> T)

Defines a dependency that will have a new instance created every time it is requested.

Link copied to clipboard
inline fun <T : Any> get(qualifier: Qualifier = TypeQualifier(T::class)): T

A helper function to resolve a dependency from the current scope. This is intended to be used within the create lambda of other dependency definitions.

Link copied to clipboard
inline fun <T : Any> scope(qualifier: Qualifier = TypeQualifier(T::class), noinline block: DependencyModuleBuilder.() -> Unit)

Defines a nested scope within the current module.

Link copied to clipboard
inline fun <T : Any> single(qualifier: Qualifier = TypeQualifier(T::class), noinline create: () -> T)

Defines a singleton dependency that will have only one instance created and shared throughout the scope's lifecycle.