Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created July 27, 2017 21:21
Show Gist options
  • Save prof3ssorSt3v3/a808cb3136c7ccb94104905296930370 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/a808cb3136c7ccb94104905296930370 to your computer and use it in GitHub Desktop.
// 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