Lazy Properties
Wanna be lazy?
WireBox supports the concept of marking properties in your components as lazy
. This will allow the property to be constructed ONCE when requested ONLY (lazy loaded). This way, you can take advantage of the construction of the property being lazy-loaded for you.
Please note that this is different than providers since in this case, you provide the function that will build the property and it can be anything you want.
Internally, we will generate a getter method for you that will make sure to construct your property via a builder function you will provide, lock the request (by default), store it in the variables
scope, and return it to you.
Note: With lazy properties, you must use the getter only to retrieve the property ONLY!
Implicit Builder
When you tag a property as lazy
, we will look for a method using the following pattern by convention:
We will lock, call the builder, store the property and return it.
Explicit Builder
If you want to use ANY method in your CFC to build the property, then use the value of the lazy
annotation to point to the public or private method that will build your property:
No Locking
By default, WireBox will lock the construction of the property. If you do not want the locking to occur, use the LazyNoLock
attribute. Just as before, if you don’t have a value for the annotation, we will look for a build{propertyName}
function, or if it has a value, we will use that as the name of the builder function.
Last updated