Closed ForbesLindesay closed 11 years ago
Implementations can of course provide suggar:
Q.isPending = function (promise) {
var isPending = true;
promise.asap(function () { isPending = false; },
function () { isPending = false; });
return isPending;
};
Q.isFulfilled = function (promise) {
var isFulfilled = false;
promise.asap(function () { isFulfilled = true; });
return isFulfilled;
};
Q.isRejected = function (promise) {
var isRejected = false;
promise.asap(undefined, function () { isRejected = true; });
return isRejected;
};
asap
in any form has been vetoed by at least two members of the Promises/A+ organization, as well as MarkM (whose opinion, as part of TC39, should not be discounted). Closing to prevent confusion from those thinking this is actively being considered for standardization under the Promises/A+ banner, but of course discussion is still welcome.
Argh wait I can't close this O_o
Promieses/A+ Extension: Synchronous Inspection
This proposal extends the Promises/A+ specification to cover synchronous inspection of a promise's fulfillment value or rejection reason.
It is not expected that all Promises/A+ implementations will include this extension. If the features of this extension are desired, you should test for them:
Motivation
TODO
Requirements: the
asap
methodA promise implementing this specification must have an
asap
method.A promises
asap
method accepts two argumentspromise.asap
must behave in the same way asthen
as described in http://promises-aplus.github.com/promises-spec/#the__method But for the purposes ofasap
3.2.4
and Notes4.1
can be ignored as asap is permitted to callonFulfilled
andonRejected
synchronously.Note
This deliberately makes the API for synchronous inspection similar to that of asynchronous inspection to discourage anti-patterns like polling for completion. It is also optimized for the common use case of a promise that may or may not be completed already.