I want a promise which will itself resolve when two promises promise1 and promise2 are BOTH resolved. How do I do this?
Here is my current horrible code:
var c = 0;
var d = $.Deferred();
promise1.then(() => {
c++;
if (c == 2) {
d.resolve();
}
});
promise2.then(() => {
c++;
if (c == 2) {
d.resolve();
}
});
return d.promise();
Is there a helper function I can call instead?