I need to wait until all promises are resolved or rejected and only then execute a callback. It seems that the current implementation of Q
triggers a callback as soon as one promise is rejected, here is the test:
var ps = [];
var d1 = $q.defer();
var d2 = $q.defer();
ps.push(d1.promise, d2.promise);
setTimeout(function () {
d1.reject()
}, 2000)
setTimeout(function () {
d2.resolve()
}, 5000)
$q.all(ps).then(function () {
// is not triggered
}).catch(function () {
//triggered after 2000 ms, I need this triggered after 5000ms
})
How can I achieve what I want?