RE: Javascript Promise Chaining

You are viewing a single comment's thread from:

Javascript Promise Chaining

in javascript •  7 years ago 

Promises are awesome! One of the main advantages over callbacks is the ability to chain promises. So you could also do something like this - I think it's more readable than nesting Promises:

add(2, 3)
  .then(response => addMore(response, 10))
  .then(response => console.log(response))

Or, if you like the bind variant:

add(2, 3)
  .then(addMore.bind(null, 10))
  .then(response => console.log(response))
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!