-
-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use AbortController
to abort fetches and more.
#4170
Comments
I think the article linked from this tweet from Dan Abramov is probably worth reading, at least in part, if only just because it's Dan Abramov. I haven't read it yet. To quote the tweet:
|
Related: #3881 |
See discussion (thanks @andersk for pointing this out, and @gnprice for nudging me to look closer!).
With facebook/react-native#24419, React Native (v0.60) gained a polyfill for the
AbortController
Web API; see the MDN doc.The MDN doc leads with this:
But it's not constrained to only work with "Web requests"; Anders links to a Google developer doc that says this:
This sounds like it's not an abomination to use it for more basic control-flow needs that have nothing to do with
fetch
or its friends. In particular, we can use this mechanism to break out of thewhile (true)
loop intryUntilSuccessful
(soon to be renamed totryFetch
in, I think, #4166), when we want to abort. (In that PR, that particular need is answered with a local stateful boolean variable—it's nice to know there's a standard, well-documented way of doing it.)And, of course, we'll actually be able to abort
fetch
requests.Fingers are crossed that this React Native polyfill works; there's some history of RN-shipped polyfills being buggy.
The text was updated successfully, but these errors were encountered: