Promise chaining

promise.then(result => result * 2).then(result => result + 1)

Return in then can also be another promise.

It is like both map and switchMap in ReactiveX. The last then is also like subscribe in Rx.

someObservable
  .map(result => result * 2)
  .switchMap(mappedResult => AnotherObservable(mappedResult))
  .subscribe(finalResult => {
    // final logic
  })
How ReactiveX (Rx) does this. Swift Combine is similar. With Promise, every next step is chained with then

Next: Promise error handling