Last active
May 18, 2019 01:56
-
-
Save dance2die/9ba18d739224d408af8a8f239cde9a2b 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 promisesWithoutReject = [ | |
| Promise.resolve('π #1'), | |
| 'π #2', | |
| new Promise((resolve, reject) => setTimeout(resolve, 100, 'π #3')) | |
| ] | |
| Promise.all(promisesWithoutReject) | |
| .then(apples => console.log(`We can sell all these good apples`, apples)) | |
| const promisesWithOneReject = [ | |
| Promise.resolve('π #1'), | |
| 'π #2', | |
| new Promise((_, reject) => setTimeout(reject, 100, 'Bad π')) | |
| ] | |
| Promise.all(promisesWithOneReject) | |
| .then(console.log) | |
| .catch(badApple => | |
| console.error(`Threw out all apples because of this`, badApple)) |
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
| We can sell all these good apples [ 'π #1', 'π #2', 'π #3' ] | |
| Threw out all apples because of this Bad π |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment