I've been recently reading about the promise([type] [,target])
function that returns a Promise object.
The documentation states that the default type
is fx
:
By default,
type
is "fx
", which means the returned Promise is resolved when all animations of the selected elements have completed.
For some reason I'm having a hard time finding other available types. I assume that other types could be e.g. ajax
which gets resolved when content is loaded into a collection using load()
or similar methods (note that I know how to handle load()
promises, I'm just giving an example).
Is there a list somewhere specifying all available types? I was thinking about looking at the source code to find that out, however I was hoping there is a list somewhere, unless fx
is the only sensible type one can use with this function.
The documentation says about the type
argument:
The type of queue that needs to be observed.
By default, all animation functions are added to the fx
queue. But with .queue
, you can "attach" functions to selected elements which are run in order to a queue of your choice (which you can define).
So, the promise would get resolved once all functions in the specified queue have been called. Though I haven't seen this in practice yet.
Example:
$('div').queue('foo', [function(next) {
setTimeout(next, 2000); // some delay
}, function(next) {
console.log('Last function in queue');
next();
}]).dequeue('foo');
$('div').promise('foo').done(function() {
console.log('all done');
});
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With