Last active
April 21, 2017 19:26
-
-
Save wcalderipe/2fe43f71a42a45cc8d26e5a72dd6892b to your computer and use it in GitHub Desktop.
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
const createTimeoutPromise = (time) => new Promise((resolve) => { | |
setTimeout(() => { | |
console.log(`resolved after ${time} secs`) | |
resolve(time) | |
}, time) | |
}) | |
console.log('creating promises') | |
const promiseB = createTimeoutPromise(2000) | |
const promiseC = createTimeoutPromise(3000) | |
const promiseA = createTimeoutPromise(100) | |
const startsAfterPromiseATime = 200 | |
setTimeout(() => { | |
console.log('promise.all them...') | |
Promise.all([promiseA, promiseB, promiseC]).then((values) => { | |
console.log(values) | |
}) | |
}, 200) | |
// creating promises | |
// resolved after 100 secs | |
// promise.all them... | |
// resolved after 2000 secs | |
// resolved after 3000 secs | |
// [ 100, 2000, 3000 ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment