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 !== promise2
is not a requirement forvar 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
onFulfilled
oronRejected
returns a thenable, including the details of the resolution procedure; - the reason passed to
onRejected
must be the thrown exception in the case where a handler throws; onFulfilled
andonRejected
must be called asynchronously;onFulfilled
andonRejected
must be called as functions;- strict ordering of calls to
onFulfilled
andonRejected
for subsequent calls tothen
on the same promise.