winter / io.jentz.winter / Component

Component

class Component

The Component stores the dependency providers which are than retrieved and instantiated by an instance of a graph.

Instances are build by calling component with a builder block.

Components are immutable but an extended variant can be created by calling derive with a builder block.

val appComponent = component {
    singleton<MyService> { MyServiceImpl(instance()) }
}
val derived = appComponent.derive {
    prototype<MyOtherService> { MyOtherServiceImpl(instance(), instance("named")) }
}
val graph = derived.createGraph { constant<Application>(myApplicationInstance) }

See Also

Builder

Types

Builder

class Builder

Properties

qualifier

val qualifier: Any

The components qualifier.

Functions

createGraph

fun createGraph(application: WinterApplication = Winter, block: ComponentBuilderBlock? = null): Graph

Create a object graph from this component.

derive

fun derive(qualifier: Any = this.qualifier, block: ComponentBuilderBlock): Component

Create an extended copy of this component.

subcomponent

fun subcomponent(vararg qualifiers: Any): Component

Returns a subcomponent by its qualifier or a nested subcomponent by its path of qualifiers.

Companion Object Properties

EMPTY

val EMPTY: Component