Book Image

Mastering JavaScript Promises

Book Image

Mastering JavaScript Promises

Overview of this book

Table of Contents (16 chapters)
Mastering JavaScript Promises
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

How do promise and deferred relate to each other?


So far, in Chapter 2, The JavaScript Asynchronous Model, we discussed promises and how they work. Let's have a look at how promises and deferred work:

  1. Every deferred object has a promise that serves as a proxy for the future result.

  2. A deferred object can be resolved or rejected by its caller, which separates the promise from the resolver, while a promise is a value returned by an asynchronous function.

  3. The promise can be given to a number of consumers and each will observe the resolution incessantly, while the resolver/deferred can be given to any number of users and the promise will be resolved by the one that first resolved it.