Imagine having 3 promises and passing them to $q.all. This results in a new promise that resolves when the 3 promises are resolved.
But what if I realize before the 3 promises resolve that I also want a 4th promise to be resolved? Can this be achieved?
I attempted something like this:
var promises = [promise1, promise2, promise3];
var allDone = $q.all(promises);
promises.push(promise4);
In the above scenario, allDone
is resolved once the first 3 promises are resolved, but I want it to wait for the 4th promise as well.
Am I misunderstanding the concept of promises here? Is there a better approach for handling such situations?
Update: It seems that $q.all doesn't support the functionality I require. So, my question is, is there an alternative method to track the resolution of a changing set of promises?