Let's say I have an async function returning a promise. I would like to chain a lot of these functions, each one with different arguments.
Function that will execute this array looks like this:
function executePromiseQueueSync(queue){
var seed = $.Deferred(),
finalPromise;
_reduce(queue, function(memo, promise){
return memo.then(promise);
}, seed.promise());
seed.resolve();
return finalPromise;
}
I saw some functions accepting an array of promises and executing them synchronously. The problem is I don't know how to create such an array. Example:
var promiseQueue = [];
promiseQueue.push(AsynchEvent(someArg)); // WRONG: this is function call and will be executed immediately
Another:
var promiseQueue = [];
promiseQueue.push(AsynchEvent); // WRONG: at some point I will have to apply this with arguments
So - is there a way to put a function returning a promise into an array without executing it?