Deferred jQuery Chain vs. jQuery.Deferred
jQuery provides another mechanism to handle deferrals – the jQuery.Deferred object:
“jQuery.Deferred, introduced in version 1.5, is a chainable utility object that can register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.”
That means jQuery.Deferred works well with callback functions. In contrast the timed invocation chain concept wants to remove as much callback functions out of your code as possible. So the timed invocation chain tries to achieve similar things like jQuery.Deferred, but they take different ways.
Nevertheless both types, the jQuery.Deferred and any deferred jQuery chain, can be used as deferred objects wherever you need some object providing a .promise()
method.
Combining deferred objects with the deferred jQuery chain
Like for animation queues there is also a possibility to join the concept of jQuery.Deferred with the deferred jQuery chain in jquery-timing. The link on the right takes you to the API description to see how an invocation chain can wait for a jQuery.Deferred object to succeed.
The other way round is also possible, because the deferred invocation chain itself is a deferred object providing a .promise()
method.
That's why it can be used like any other deferred object.
Hence it can be used even in other invocation chains to wait for. Or you use it toegther with $.when(…)
.