var array = [DefferdObj, DefferdObj, DefferdObj, DefferdObj];
array[0].then
array[1].then
array[2].then
・
・
・
I want to execute DefferedObj asynchronously. This array can be changed dinamically.
var array = [DefferdObj, DefferdObj, DefferdObj, DefferdObj];
array[0].then
array[1].then
array[2].then
・
・
・
I want to execute DefferedObj asynchronously. This array can be changed dinamically.
If you are looking to run a piece of code after they all complete then:
$.when.apply(null, array).then(function() {
console.log("all deferreds in array are complete!");
});
If you are looking to control the order the deferreds run, you will have to be sure the deferreds haven't already started. Before you put them in the array, I would suggest wrapping them in an ongoing deferred.
var last = array[0];
function tackOnFunction(fn) {
array.push(last = last.then(fn));
}