Last active
January 23, 2017 17:17
-
-
Save solominh/1dc5f6e02bd50bb08c2ca4d1c12ce8a0 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
| // Catch function before then function | |
| var a = Promise.reject('ErrorValue') | |
| .catch((err) => { | |
| console.log('Catch', 'PromiseValue', err) | |
| }) | |
| .then((data) => { | |
| console.log('Then', 'PromiseValue', data) | |
| }) | |
| // Then function before catch function | |
| var b = Promise.reject('ErrorValue') | |
| .then((data) => { | |
| console.log('Then', 'PromiseValue', data) | |
| }) | |
| .catch((err) => { | |
| console.log('Catch', 'PromiseValue', err) | |
| }) | |
| // Return new promise value | |
| var c = Promise.reject('ErrorValue') | |
| .catch((err) => { | |
| console.log('Catch', 'PromiseValue', err) | |
| return 'NewPromiseValue' | |
| }) | |
| .then((data) => { | |
| console.log('Then', 'PromiseValue', data) | |
| }) | |
| // Return new promise | |
| var d = Promise.reject('ErrorValue') | |
| .catch((err) => { | |
| console.log('Catch', 'PromiseValue', err) | |
| return Promise.resolve('ResolvedValue') | |
| }) | |
| .then((data) => { | |
| console.log('Then', 'PromiseValue', data) | |
| }) | |
| // Multiple then functions | |
| var e = Promise.reject('ErrorValue') | |
| .catch((err) => { | |
| console.log('Catch', 'PromiseValue', err) | |
| return Promise.resolve('ResolvedValue') | |
| }) | |
| .then((data) => { | |
| console.log('Then1', 'PromiseValue', data) | |
| }) | |
| .then((data) => { | |
| console.log('Then2', 'PromiseValue', data) | |
| }) | |
| .then((data) => { | |
| console.log('Then3', 'PromiseValue', data) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment