Fulfillment The asynchronous analog for returning a value. When a successful promise is fulfilled, all of the pending callbacks are called with the value. If more callbacks are registered in the future, they will be called with the same value.

Rejection The asynchronous analog for throwing an exception. When a promise cannot be fulfilled, a promise is 'rejected' which invokes the errbacks that are waiting and remembers the error that was rejected for future errbacks that are attached.

Resolution A promise is resolved when it makes progress toward fulfillment or rejection. A promise can only be resolved once, and it can be resolved with a promise instead of a fulfillment or rejection.

then() The method by which one attaches a callback, errback and/or progressback to a promise.

when() The method by which one attaches a callback, errback and/or progressback to an object that may not be a promise.

Facts, Thoughts and Opinions

General Rules for Using Promises

Excerpted from an answer to this question.

  1. Every function that does something asynchronous must return a promise.
  2. Create an immediate wrapper for every function that doesn't do something asynchronous.
  3. Everything that does something with an asynchronous result goes into a .then callback.

The Promise Contract

There is one, and only one, resolution or rejection. A promise is resolved one time. It will never be fulfilled if it has been rejected or rejected if it has been fulfilled.

Listeners are executed one time. An individual callback or errback will be executed once and only once. This follows from the first rule of the contract.

A promises remembers its state. A promise that is resolved with a value remembers the fulfillment. If a callback is attached in the future to this promise, it will be executed with the previously resolved value. The same is true of errbacks. If a promise is rejected and an errback is attached after the rejection, it will be executed with the rejected value. Promises behave the same way regardless of whether they are already resolved or resolved in the future.


  •   Subtopics

  •   Writings

  Sources & Bookmarks