Created
February 4, 2019 15:44
-
-
Save munkacsitomi/359aea746410e90a49bbd0899babb7f6 to your computer and use it in GitHub Desktop.
Promise Flow example
This file contains hidden or 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
console.time("Promise flow"); | |
const promises = [ | |
Promise.resolve(console.log("Promises array has begun executing")), | |
new Promise((resolve) => | |
setTimeout(() => resolve(console.log("Initial Promise resolving after:", 5000)), 5000) | |
)]; | |
Promise.all(promises).then(() => console.timeEnd("Promise flow")) | |
promises.push( | |
new Promise((resolve) => | |
setTimeout(() => resolve(console.log("Added Promise resolving after:", 10000)), 10000) | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment