Created
July 27, 2017 21:21
-
-
Save prof3ssorSt3v3/a808cb3136c7ccb94104905296930370 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
// Promise.all() | |
//when you only want to run your code after ALL | |
// your promises are resolved. | |
// EG: fetching remote data from multiple locations | |
let p1 = () => Promise.resolve('Got the list of users'); | |
let p2 = () => Promise.resolve('Got the list of tweets'); | |
let p3 = Promise.resolve('Got the weather'); | |
Promise.all([p1(), p2(), p3]).then((resultsArr)=>{ | |
console.log( resultsArr[1] ); | |
console.log( resultsArr[0] ); | |
console.log( resultsArr[2] ); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment