Created
November 2, 2016 15:16
-
-
Save FTAndy/7a2b88963fc4c7a5e834cefc44b1ac75 to your computer and use it in GitHub Desktop.
Promise synchronize array promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let results = [] | |
dataArray.reduce((prePromise, data) => { | |
return prePromise.then(() => { | |
return dosomethingWithData(data) | |
.then((result) => { | |
results.push(result) | |
}) | |
}) | |
}, Promise.resolve()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment