Skip to content

Instantly share code, notes, and snippets.

@clarkio
Last active September 22, 2017 14:43
Show Gist options
  • Save clarkio/aa9b33349876826d0dd9caca302c16ad to your computer and use it in GitHub Desktop.
Save clarkio/aa9b33349876826d0dd9caca302c16ad to your computer and use it in GitHub Desktop.
// 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