Eager or Lazy Bindings
@Eager
and @Lazy
annotations can be used to control when bindings are evaluated. In the absence of either annotation, bindings will be evaluated every time they are referenced and discarded once used.
@Eager
Since v3.9.0
The @Eager
annotation can be used to immediately evaluate a binding. The eagerly bound value is instantly returned whenever the name is referenced.
Given @Eager time is defined by js "new Date().getTime()"
When I capture time as time 1
And I capture time as time 2
Then time 1 should be "${time 2}"
time 1
and time 2
will have the same value since time
is evaluated and bound immediately at step 1.
@Lazy
Since v3.9.0
The @Lazy
annotation can be used to evaluate bindings when they are first referenced. The lazily bound value is returned whenever the name is referenced thereafter.
Given @Lazy time is defined by js "new Date().getTime()"
When I capture time as time 1
And I capture time as time 2
Then time 1 should be "${time 2}"
time 1
and time 2
will have the same value since time
is bound and evaluated when it is first referenced.
Default (ephemeral)
Since v1.0.0
In the absence of either annotation, the bindings will be unconditionally evaluated every time the name is referenced without being saved to memory. This is the default behaviour.
Given time is defined by js "new Date().getTime()"
When I capture time as time 1
And I capture time as time 2
Then time 1 should not be "${time 2}"
time 1
and time 2
will have different values since time
is evaluated, bound and discarded at steps 2 and 3.