new CallbackChain(aCallbacks)
This CallbackChain class is used to hold
a list of chained callbacks and it can often be passed instead
of a callback. Caveat: This will not chain synchronous functions
which expect a return value. It is mainly designed for async
calls but you could probably make it chain sync calls by making
your synchronous code use the callbacks to pass data back in
method arguments and avoid using 'return' to pass back data.
Note that the first element (item 0) of the callbacksChain array
is at the innermost or deepest nested level, in other words it
represents the method to be called first. The code here ensures
that you cannot add callback chain objects as elements to the
callbacksChain array (that would be too confusing, for me at
least) but you can use the addNewCallback() method to add a new
callback as the first item in the array (which becomes the first
to be called). To use this, the function that is called back
should expect to receive a callbackChain as the final argument
(if it needs to call a subsequent outer level callback).
Parameters:
Name | Type | Description |
---|---|---|
aCallbacks |
Array.<(jsx.Callback|jsx.CallbackCustom)> | an array containing module:obitech-framework/jsx#Callback and/or module:obitech-framework/jsx#CallbackCustom objects (a mixture is OK) |