open class WinterTree
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")
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. |
fun close(vararg path: Any): Unit
Remove and dispose the object graph and its subgraphs stored in path. |
|
fun closeIfOpen(vararg path: Any): Boolean
Remove and dispose the object graph and its subgraphs stored in path if it is open. |
|
fun create(vararg path: Any, block: ComponentBuilderBlock? = null): Graph
Create and return an object graph by (sub-)component path without registering it. |
|
fun get(vararg path: Any): Graph
Get a registered object graph by path. |
|
fun has(vararg path: Any): Boolean
Returns true if an entry under the given path exists otherwise false. |
|
fun open(vararg path: Any, identifier: Any? = null, block: ComponentBuilderBlock? = null): Graph
Create a object graph by (sub-)component path and register it. Opened object graphs will be children of each other in left to right order. |
object GraphRegistry : WinterTree
An object version of WinterTree that uses Winter as its WinterApplication. |