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 databaseGetUser = id => | |
| id === 'not-exists' | |
| ? Promise.reject('some weird database error') | |
| : Promise.resolve({id, username: 'username'}) | |
| const databaseGetPosts = user => | |
| user.id === 'fail-to-get-posts' | |
| ? Promise.reject('some weird database error') | |
| : Promise.resolve([{title: 'A'}, {title: 'B'}]) |
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 databaseGetUser = id => | |
| id === 'not-exists' | |
| ? Promise.reject('some weird database error') | |
| : Promise.resolve({id, username: 'username'}) | |
| function getUser(id) { | |
| return databaseGetUser(id) | |
| .catch(err => { throw 'user doesn\'t exists' }) | |
| } |
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.reject('some error') | |
| .catch(err => { throw 'earth is not flat' }) // runs | |
| .catch(err => console.log(err)) // logs 'earth is not flat' |
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.reject('some error') | |
| .catch(err => { throw err }) // runs | |
| .catch(err => console.log(2)) // runs |
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.reject('some error') | |
| .catch(err => console.log(1)) // runs | |
| .catch(err => console.log(2)) // never runs |
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
| function someHellComputation(initialData) { | |
| return fnA(initialData) | |
| .then(fnB) | |
| .then(fnC) | |
| } | |
| someHellComputation(10) | |
| .then(console.log) | |
| .catch(err => { | |
| // where does err come from: fnA, fnB, fnC? |
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
| function someHellComputation(initialData) { | |
| return fnA(initialData) | |
| .then(fnB) | |
| .then(fnC) | |
| } | |
| someHellComputation(10) | |
| .then(console.log) | |
| .catch(console.error) |
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
| function someHellComputation(initialData, callback) { | |
| fnA(initialData, (err, intermediateData) => { | |
| if (err) return callback(err) | |
| fnB(intermediateData, (err, anotherData) => { | |
| if (err) return callback(err) | |
| fnC(anotherData), (err, finalData) => { | |
| if (err) return callback(err) | |
| callback(null, finalData) |
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 arr = [ | |
| { | |
| id: 10, | |
| title: "Test 10", | |
| item: "Item 1" | |
| }, | |
| { | |
| id: 10, | |
| title: "Test 10", | |
| item: "Item 2" |
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
| import lazyLoadingRoutes from '../../support/lazyLoadingRoutes' | |
| export default lazyLoadingRoutes([ | |
| { path: '/login', component: 'Login', meta: { requiresAuth: false } }, | |
| { path: '/forgotPassword', component: 'ForgotPassword', meta: { requiresAuth: false } }, | |
| { path: '/forgotEmail', component: 'ForgotEmail', meta: { requiresAuth: false } }, | |
| { path: '/createAccount', component: 'CreateAccount', meta: { requiresAuth: false } } | |
| ]) | |