Last active
September 22, 2017 14:43
-
-
Save clarkio/aa9b33349876826d0dd9caca302c16ad to your computer and use it in GitHub Desktop.
This file contains 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
// callbacks | |
foo(params, function (error, fooResult) { | |
bar(fooResult, function (error, barResult) { | |
baz(barResult, function (error, bazResult) { | |
// and on and on... >>>>>>> | |
}); | |
}); | |
}); | |
// vs. | |
// promises | |
foo(params) | |
.then(bar) | |
.then(baz) | |
.catch(handleError); | |
function handleError(error) { | |
// ... | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment