Differences from Promises/A
Promises/A+ is based on the concepts and
then API presented in the CommonJS Promises/A proposal. However, it differs from Promises/A in several important ways.
The following parts of Promises/A have been intentionally omitted:
- Progress handling: in practice, it has proven to be underspecified and currently does not have an agreed-upon or de facto behavior within the promise implementor community.
- Interactive promises: this is deemed out of scope of the minimal API necessary for interoperable promises.
promise1 !== promise2is not a requirement for
var promise2 = promise1.then(onFulfilled, onRejected).
Promises/A+ uses different terminology from Promises/A, reflecting what has become the de facto vocabulary among promise implementations. Specifically:
- The promise states are given as "pending", "fulfilled", and "rejected".
- When promises are fulfilled, they have a "value"; when they are rejected, they have a "reason".
- It introduces the term "thenable" as distinct from "promise", so as to more precisely talk about the duck-typing tests necessary for implementation interoperation.
Promises/A+ additionally specifies:
- the behavior in the case where
onRejectedreturns a thenable, including the details of the resolution procedure;
- the reason passed to
onRejectedmust be the thrown exception in the case where a handler throws;
onRejectedmust be called asynchronously;
onRejectedmust be called as functions;
- strict ordering of calls to
onRejectedfor subsequent calls to
thenon the same promise.