Back to Basics: Running Promises in Serial with Array.reduce()
https://decembersoft.com/posts/promises-in-serial-with-array-reduce/
const tasks = getTaskArray();return tasks.reduce((promiseChain, currentTask) => { return promiseChain.then(chainResults => currentTask.then(currentResult => [ ...chainResults, currentResult ] ) );}, Promise.resolve([])).then(arrayOfResults => { // Do something with all results});
Back to Basics: Running Promises in Serial with Array.reduce()
https://decembersoft.com/posts/promises-in-serial-with-array-reduce
const tasks = getTaskArray();return tasks.reduce((promiseChain, currentTask) => { return promiseChain.then(chainResults => currentTask.then(currentResult => [ ...chainResults, currentResult ] ) );}, Promise.resolve([])).then(arrayOfResults => { // Do something with all results});
ES6 Promises in Depth
http://ponyfoo.com/articles/es6-promises-in-depth
Promises are a very involved paradigm, so we’ll take it slow.