Git Product home page Git Product logo

Comments (10)

mysticatea avatar mysticatea commented on June 18, 2024 2

I'm not sure what this issue's goal.

This is not the polyfill of the fetch API. This is an isomorphic implementation of AbortController API. The fetch API is merely one of APIs which depend on the AbortController API. The AbortController API does not depend on the fetch API. The dependency is not bi-directional.

from abort-controller.

mysticatea avatar mysticatea commented on June 18, 2024 1

For example, if you want to implement a polyfill of the whole fetch API, you can use this package, then it may reduce duplicate code with the polyfills of other APIs which depend on AbortController (AbortController is a standard API for aborting asynchronous jobs in WHATWG layer). Especially, if the polyfill aims at isomorphic, this package would be useful since this works on Node.js as well.

Of course, if you are interested in only modern browsers, you don't need this package.

from abort-controller.

quisido avatar quisido commented on June 18, 2024

@mysticatea

from abort-controller.

mysticatea avatar mysticatea commented on June 18, 2024

I'm sorry for the overlook.

You can use this package on browsers normally. Just import it by a script element or use Webpack or something like.

AbortController provides the feature that notifies abort events to subscribers. It's all. This shim doesn't touch what the subscribers of abort event do.

from abort-controller.

quisido avatar quisido commented on June 18, 2024

@mysticatea So you're saying that if I fetch something in Internet Explorer 6, this AbortController will be able to abort that request? I am asking what browsers this gives functionality to that don't already support AbortController. I know that abort is not supported by many browsers, so I am wondering how many browsers this is capable of giving abort functionality to. Or maybe I am misunderstanding the purpose of the repo.

from abort-controller.

mysticatea avatar mysticatea commented on June 18, 2024

No. This is an implementation of AbortController API, but this is not a polyfill of fetch. The fetch API accepts signal option and subscribes the abort event, but it's a feature of the fetch API.

from abort-controller.

quisido avatar quisido commented on June 18, 2024

@mysticatea So right now, I am able to use AbortController as built into Chrome. Why import an implementation of AbortController when the browser already supports it?

I presume the reason is to polyfill browsers that support abort but not AbortController.

from abort-controller.

mysticatea avatar mysticatea commented on June 18, 2024

AbortController is an independent API for all features which need to abort ongoing activities. In the spec, Aborting ongoing activities section mentions it.

Originally, people have needed the standard way to cancel asynchronous jobs, and it had discussed as cancellable promises in TC39. However, the cancellable promises spec had been withdrawn. So people defined the standard way in WHATWG.

I think there are several APIs need the way which aborts asynchronous jobs. It's convenient if the way is common in all Web APIs. And WHATWG mentions that AbortController is the common way.

I expect the polyfills of the APIs which depend on AbortController to use this package rather than each polyfill implements it.

from abort-controller.

quisido avatar quisido commented on June 18, 2024

@mysticatea Maybe this is more clear:
Do you know which browser versions support signals on fetch (fetch(..., { signal: ...})) but do not support AbortController?

This is essentially a polyfill for AbortController, right? If AbortController isn't defined in your browser, this defines it. AbortController comes built into Chrome 66, Edge 16, Firefox 57, Opera 43, and Safari 11.1.
If I am using one of the aforementioned browsers that innately supports AbortController, this package is unnecessary, right?
This package is for browsers that do not have support for AbortController already built in.

My question is, if a browser does not innately support AbortController, why define it?
I am under the impression that a browser that does not innately support AbortController also does not support the signal option on fetch.

What does a polyfill of AbortController do if it can't abort a fetch request?
Are there browsers that can abort a fetch request but do not have AbortController built in?

from abort-controller.

quisido avatar quisido commented on June 18, 2024

@mysticatea

I am under the impression that any browser that supports the signal option of fetch already supports AbortController without a polyfill. And that any browser that does not have AbortController innately available does not support the signal option of fetch.

That is to say that adding an AbortController polyfill does nothing if the browser does not support signal on fetch in the first place. For example, Chrome 65 does not have innate AbortController support. Using this polyfill does not allow fetch to be aborted, because the signal option of fetch is completely ignored.

Why polyfill it if it does nothing?
Are there browsers that do have signal support on fetch but do not have AbortController innately available?

Again, for example, I used this polyfill on Chrome 65, and it did nothing, because Chrome 65 does not support signal on fetch.
On Chrome 66, where signal is a supported option of fetch, AbortController is already defined innately, and so this polyfill still does nothing.

from abort-controller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.