Skip to content

Instantly share code, notes, and snippets.

@maruf89
Last active August 29, 2015 14:22
Show Gist options
  • Save maruf89/5c9e3ff21e39d848cd66 to your computer and use it in GitHub Desktop.
Save maruf89/5c9e3ff21e39d848cd66 to your computer and use it in GitHub Desktop.
Promise chaining styles
//// 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