winter / io.jentz.winter / WinterTree / <init>

<init>

WinterTree(application: WinterApplication)

WinterTree acts as an holder for the application object graph and is a helper for opening, closing and accessing subgraphs by paths of identifiers.

Instances of WinterTree are usually not used directly but in injection adapters.

This is inspired by Toothpicks openScope/closeScope mechanism, if you like that, you can simply use GraphRegistry instead of the Injection abstraction.

Example:

// register the application component
Winter.component {
  // ... the component definition
}
val tree = WinterTree(Winter)

// open the application graph
tree.open()
// or supply a builder block to extend the resulting graph
tree.open { constant<Application>(myApplication) }

// the application graph can then be accessed by calling
tree.get()

// to open a subgraph call
tree.open("subcomponent qualifier")

// this graph can be accessed by calling
tree.get("subcomponent qualifier")

// you can provide an optional identifier for the subgraph
tree.open("subcomponent qualifier", identifier = "other name")

// then you can access the the subgraph by calling
tree.get("other name")

// to open a subgraph of this call
tree.open("subcomponent qualifier", "sub-subcomponent qualifier")
// respectively
tree.open("other name", "sub-subcomponent qualifier")