O'Reilly logo

Async JavaScript by Trevor Burnham

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

Combining Promises

The existence of progress notifications doesn’t change the fact that, ultimately, every Promise is either resolved or rejected. (Or, it remains pending for eternity.) But why? Why not let Promises change to any state at any time?

Mainly, Promises are designed this way because programmers thrive on binary. We know exactly how to put 1s and 0s together to perform astounding feats of logic. That’s a big reason why Promises are so powerful; they let us treat tasks as booleans.

The most common use case for logically combining Promises is finding out when a set of async tasks has finished. Let’s say you’re showing a tutorial video while loading a game from the server. You want to start the game as soon as two things have happened, ...

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