How can I synchronously determine a JavaScript Promise's state?

Ron Waldon jokeyrhyme at gmail.com
Mon Jun 1 21:29:12 UTC 2015


I have lodged the following question on StackOverflow:
http://stackoverflow.com/questions/30564053/how-can-i-synchronously-determine-a-javascript-promises-state

I have also lodged it as a proposal on Specifiction:
http://discourse.specifiction.org/t/how-can-i-synchronously-determine-a-javascript-promises-state/866

I have a pure JavaScript Promise (built-in implementation or poly-fill):

`var promise = new Promise(function (resolve, reject) { /* ... */ });`

>From the [specification](
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects),
a Promise can be one of:

- 'settled' and 'resolved'
- 'settled' and 'rejected'
- 'pending'

I have a use case where I wish to interrogate the Promise synchronously and
determine:

- is the Promise settled?
- if so, is the Promise resolved?

It appears there is no API for synchronous interrogation of a Promise's
state. Can we please make this part of a future specification?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150601/0f2c26f7/attachment-0001.html>


More information about the es-discuss mailing list