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

Re: [whatwg] Promise.every() arguments

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 20 Aug 2013 14:00:29 -0700
Message-ID: <CAAWBYDAvyehZPohpbOrGDpgpdimv-VY8LbUALdE+D_iS2M=jDQ@mail.gmail.com>
To: Alec Flett <alecflett@chromium.org>
Cc: WHATWG <whatwg@lists.whatwg.org>
On Tue, Aug 20, 2013 at 1:42 PM, Alec Flett <alecflett@chromium.org> wrote:
> I've been doing a lot of experimentation with Promises using the Blink
> implementation. I've frequently hit an issue with the .every() / .any() /
> .some()
>
> the problem is that they support a variable number of arguments. This seems
> very developer friendly in theory, as per the docs:
>
> Promise.every(fetchJSON(foo), fetchJSON(bar), fetchJSON(baz));
>
> This is great the first time you play with it on your local developer
> console.
>
> The problem arises in practice: it's very common to build up arrays of N
> promises, and then tie them all together. Even if your own API uses
> varargs, using Promise.every breaks down.

ES6 has array spreading, so you can do `Promise.every(...pending)`.
This already works in Firefox, and V8 (Chrome's JS engine) is adding
these kinds of features as well.

~TJ
Received on Tuesday, 20 August 2013 21:01:19 UTC

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