tiny-deferred
Does what it says on the tin and does it well. That is all.
Howto
The only events are done
, fail
and always
.
var def = ;
Once an instance has been resolved or rejected, it can't be resolved or rejected again. However, adding a done
, fail
or always
callback to a rejected object will result in the callback function being called immediately with the expected arguments and context.
def; // Many lines of code later...def ;
Returning any kind of value (null included) from a callback will cause that value to be passed as the first argument to subsequent callbacks. This feature allows us to create an interesting onion-skin pattern, morphing data as it passes through the layers of callbacks.
def; // Many lines of code later...def;
Context can be supplied to callbacks by calling the resolveWith
or rejectWith
methods. The context is the same for all callbacks, even those added and fired after resolution or rejection.
;
Arrays of functions may be passed to the callback methods.