O'Reilly logo

Mastering Web Application Development with AngularJS by Pawel Kozlowski, Peter Bacon Darwin

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

The promise API with $q

JavaScript programmers are accustomed to the asynchronous programming model. Both a browser and the node.js execution environments are full of asynchronous events: XHR responses, DOM events, IO and timeouts, which can be triggered at any moment and in random order. Even if, we are all used to coping with the asynchronous nature of the execution environment the truth is that asynchronous programming might be perplexing, especially when it comes to synchronizing multiple asynchronous events.

In the synchronous world chaining function calls (invoking a function with a result of another function) and handling exceptions (with try/catch) is straightforward. In the asynchronous world, we can't simply chain function calls; we need ...

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