I'm using
$.when.apply($, arrayOfDeferreds).then(function() {
var args = Array.prototype.slice.call(arguments);
var anotherArrayOfDeferreds = [];
args.map(function(item){
anotherArrayOfDeferreds.push(item.getSomething()); // item.getSomething() returns an deferred.
});
// return an anotherArrayOfDeferreds
});
to deal with an array of deferreds.
However, in (do something here ...) above, it generates another array of deferreds, which essentially needs another $.when.apply() and which cannot be dealt with by .then()
. I am wondering if there is a way to chain $.when?
Thanks!
I think you can pass it again to
$.when
to create a new promise which can be returned from thethen
to make it chainable