Last active
August 29, 2015 14:22
-
-
Save maruf89/5c9e3ff21e39d848cd66 to your computer and use it in GitHub Desktop.
Promise chaining styles
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
//// If short | |
fnThatReturnsPromise('some val').catch(function () { | |
// handleError | |
}).then(functionThatLogsSomething) // Here we're assuming that there's no way this function can error out. If it can then do the next format | |
//// Or | |
// One pair | |
fnThatReturnsPromise('some val').catch(function () { | |
// handleError | |
}) | |
// comments about second pair | |
.then(function () { | |
// Something that might throw an error | |
}).catch(function (err) { | |
// Error from previous then | |
}) | |
// third pair - repeat format | |
.then(//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment