W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2015

Re: [whatwg] Array as first argument to fetch()

From: Brett Zamir <brettz9@yahoo.com>
Date: Fri, 27 Mar 2015 20:50:01 +0800
Message-ID: <551551F9.2040307@yahoo.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: whatwg <whatwg@whatwg.org>
On 3/27/2015 8:39 PM, Anne van Kesteren wrote:
> On Fri, Mar 27, 2015 at 1:28 PM, Brett Zamir <brettz9@yahoo.com> wrote:
>> Since fetch() is making life easier as is and in the spirit of promises, how
>> about taking it a step further to simplify the frequent use case of needing
>> to retrieve multiple resources and waiting for all to return?
>> If the first argument to fetch() could be an array, then fetch() could be
>> made to work like Promise.all() and return an array of the results to
>> then().
> It seems easy enough to just write that yourself, e.g.
>    Promise.all(["image", "script"].map(url => fetch(url)))
> works fine in Firefox Nightly.

Thanks, I realize it's doable that way, but I think it makes for less 
distracting code when the implementation details of the map call and 
such are avoided for something as basic as loading resources...

Received on Friday, 27 March 2015 12:50:31 UTC

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