singlein the above example takes two arguments:
() => DateTime.now().difference(use(dobKey)).inYears
singlevalue is calculated once by calling the
factorymethod when the
runmethod is called. The calculated factory value is then fixed for the life of the Scope.
valuesdeclared in the same scope (or a parent scope). This is the main difference between the
singlecall on line 4 and the
valuecall on line 3. Both call functions but the
factorymethod has access to other 'in Scope' variables where as the value call does not.
sequencevalue is injected in a similar way to the
singlevalue. The difference is that the
sequencemethod is NOT called when the run method is called but each time the
usemethod is called with the
sequencecan be used to recalculate a value each time it is used and could be used to provide a sequence of values (such as a counter or a random number generator).