RE: RE: Javascript Promise Chaining
You are viewing a single comment's thread from:

RE: Javascript Promise Chaining

Words
39
Reading
1 min
Listen
Play
9y

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))
@petarjs: Promises are | Ecency