I have two promises, one is likely to be very slow and the other one is going to be faster. I understand that Promise.all
is all or nothing so when the slow one timeouts it causes the other one to not show result as well. Is there anyway I can run two Promises in the same time and if the slow one fails I can still get the result from the fast one without doing a lot of callbacks?
I googled and I can't seem to find an example of
var pList = [slowQuery({url: url}), fastQuery({url: url})];
Promise.all(pList).then(function doneFunc(results) {
output.slow = results[0];
output.fast = results[1];
window.respond(output);
}).catch(function errFunc() {
output.slow = [];
output.fast = [];
window.respond(output);
});
}