JSFiddle - React, Tailwind, and code Playground
by joepenzo
JavaScript
console.log('0');
function asyncAction(i) {
return new Promise(function(resolve, reject) {
var result = calculateResult();
if (result.hasError()) {
return reject(result.error);
}
return resolve(result);
});
}
console.log('1');
var promises = [];
console.log('2');
for (var i=0; i < 10; i++) {
promises.push(asyncAction(i));
}
console.log('3');
Promise.all(promises).then(function AcceptHandler(results) {
handleResults(results),
}, function ErrorHandler(error) {
handleError(error);
});
console.log('4');