Skip to content

Instantly share code, notes, and snippets.

@munkacsitomi
Created February 4, 2019 15:44
Show Gist options
  • Save munkacsitomi/359aea746410e90a49bbd0899babb7f6 to your computer and use it in GitHub Desktop.
Save munkacsitomi/359aea746410e90a49bbd0899babb7f6 to your computer and use it in GitHub Desktop.
Promise Flow example
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