W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2013

Re: [whatwg] How works Promise.any() if it was called with resolved promises?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 14 Jun 2013 17:51:45 +0200
Message-ID: <CAAWBYDBWj8hNi=CS1rUVhz2+eATy8Ang-ScsqoW9ogskvaevPA@mail.gmail.com>
To: Tetsuharu OHZEKI <saneyuki.snyk@gmail.com>
Cc: WHATWG <whatwg@lists.whatwg.org>
On Fri, Jun 14, 2013 at 5:36 PM, Tetsuharu OHZEKI
<saneyuki.snyk@gmail.com> wrote:
> 2013/6/15 Tab Atkins Jr. <jackalmage@gmail.com>:
>> On Fri, Jun 14, 2013 at 5:00 PM, Tetsuharu OHZEKI
>> <saneyuki.snyk@gmail.com> wrote:
>> If you check out the spec, Promise.any() runs down its list of
>> arguments in order, giving them the ability to resolve the returned
>> promise.  So if several of them are already resolved, the first one in
>> argument order is what gets used - the rest of them *try* to fulfill
>> the promise, but it's already been resolved, so it doesn't do
>> anything.
> Oh, thank you!
> I confused the spec description... I get the point by your comment.
> So the following is confirmation:
> * `Promise.any()`'s fulfillCallback is called once when the one in
> argument order has been resolved.
> * If the first one in argument order has been resolved, its state will
> decide the state of the promise returned from `Promise.any()`.
> * Values of resolved promises in argument order are passed to
> `Promise.any()`'s fulfillCallback.

Promise.any() only passes the *first* argument's fulfill value to its
callback, not all of them (even if it was called with several
already-fulfilled arguments).

Otherwise, you're right.

Received on Friday, 14 June 2013 15:52:32 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:00 UTC