Last active
September 28, 2015 12:52
-
-
Save qubyte/0ec81ab787ce737a3bd5 to your computer and use it in GitHub Desktop.
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
const promises = ['some promises in here']; | |
const waitForPromises = asyncRunner(function* (promises) { | |
for (const promise of promises) { | |
yield promise; | |
} | |
// At this point all the promises have resolved. | |
}); | |
// vs | |
const waitForPromises = asyncRunner(function* (promises) { | |
yield Promise.all(promises); | |
// At this point all promises have resolved. | |
}); | |
// Bonus... async-await just progressed to stage 3, so one day (or now with babel) you'll be able to do this: | |
const waitForPromises = async function (promises) { | |
for (const promise of promises) { | |
await promise; | |
} | |
}; | |
// or | |
const waitForPromises = async function (promises) { | |
await Promise.all(promises); | |
}; | |
// but that's obviously redundant. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment