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

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

From: Tetsuharu OHZEKI <saneyuki.snyk@gmail.com>
Date: Sat, 15 Jun 2013 00:00:09 +0900
Message-ID: <CACyPx=nB0U7uZXrCC+oNKCQdgU-caO3atV=Qqh5afSSxfHokVg@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: WHATWG <whatwg@lists.whatwg.org>
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?
});

```

2013/6/14 Tab Atkins Jr. <jackalmage@gmail.com>:
> On Fri, Jun 14, 2013 at 2:25 PM, Tetsuharu OHZEKI
> <saneyuki.snyk@gmail.com> wrote:
>> I have questions about DOM Promise.
>>
>> If we call `Promises.any()` with resolved promises, how does it
>> execute its fulfillCallback?
>
> The returned promise is immediately fulfilled, so the callback will be
> called in the next tick.
>
> Remember, the whole point of promises is that you can add new
> callbacks before *or* after the promise is resolved, and it'll work
> either way.
>
> ~TJ



--
Tetsuharu OHZEKI
(a.k.a saneyuki_s)
Received on Friday, 14 June 2013 15:00:53 UTC

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