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:06:00 +0200
Message-ID: <CAAWBYDDBEhTRsnb_CWnnwPAN=Qvif8J6fMpfX_H8HFngc9NVew@mail.gmail.com>
To: Tetsuharu OHZEKI <saneyuki.snyk@gmail.com>
Cc: WHATWG <whatwg@lists.whatwg.org>
On Fri, Jun 14, 2013 at 5:00 PM, Tetsuharu OHZEKI
<saneyuki.snyk@gmail.com> wrote:
> Thank you.
>
> By the way, if we call `Promise.any()` with some resolved and rejected
> promises  and add new fulfillCallback to it, will the fulfillCallback
> be invoked once with parameters which are values of all promises
> passed to `Promises.any()`?  Or will the fulfillCallback be invoked
> with values which are resolved promises only?
>
> like this case:
> ```
> // p1, p2 are resolved promises. p3 is pending, rejected, or resolved one.
> Promise.any(p1, p2, p3).then(function fulfillCallback(){
>   // What will this function be passed?
> });

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.

~TJ
Received on Friday, 14 June 2013 15:06:44 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:22 UTC