Eager Init
Another aspect of our objects is when are they created? Good question!
By default all objects are created ONLY when they are requested, in other words they are lazy created. But what if you are spoiled and you want your stuff NOW NOW NOW! Well, you can, cry if you want to! Just tell WireBox that you want your objects to be eagerly created via the mapping DSL asEagerInit() function or a eagerInit annotation on the component.
1
component extends = "wirebox.system.ioc.config.Binder" {
2
3
function configure(){
4
5
// map with shorthand or full scope notation
6
mapPath("model.Coffeshop")
7
.asSingleton()
8
.asEagerInit();
9
}
10
11
}
12
13
/**
14
* Eager Component via Annotation
15
*/
16
component singleton eagerInit{
17
18
}
Copied!
Copy link