O'Reilly logo

jQuery Design Patterns by Thodoris Greasidis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chaining Promises

Every invocation of the then() method returns a new Promise, whose both final status and result depends on the Promise that the then() method was called on, but is also subject to the value returned by the attached callbacks. This allows us to chain calls of the then() method, enabling us to compose Promises by serially joining them. This way, we can easily orchestrate both asynchronous and synchronous code, where each chaining step propagates its result to the next one and allows us to construct the final result in a readable and declarative way.

Let's now proceed to analyzing all the different ways that chaining of calls to the then() method works. Since we will be focusing on the concepts of Promise composition by chaining, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required