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

Re: [whatwg] Fetch: use separate methods instead of one `to` method in FetchBodyStream

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 18 Jun 2014 18:08:32 +0800
Message-ID: <CA+c2ei-TJmL+eZVpv0vspwuASqHzda1jw2mnHWYppk1gV25LvA@mail.gmail.com>
To: Jussi Kalliokoski <jussi.kalliokoski@gmail.com>
Cc: WHATWG <whatwg@whatwg.org>
On Mon, Jun 16, 2014 at 6:57 PM, Jussi Kalliokoski
<jussi.kalliokoski@gmail.com> wrote:
>
> var doesFetchSupportJson = function () {
>     return fetch("data:application/json;base64,e30=").then(function
> (response) {
>         return response.body.to("json");
>     }).then(function () {
>         return true;
>     }).catch(function () {
>         return false;
>     });
> };

I agree with this. We're told time and again that feature detection is
important, as is the ability to polyfill. It seems like the current
API fails both these tests.

The above code shows that it can be worked around, but only asynchronously.

What is the advantage of the current design? The number of functions
is very indicative of complexity, so I don't see a reason to avoid
having separate functions rather than string arguments here.

/ Jonas
Received on Wednesday, 18 June 2014 10:09:27 UTC

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