-
-
Notifications
You must be signed in to change notification settings - Fork 673
Description
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:
The
AbortController
interface represents a controller object that allows you to abort one or more Web requests as and when desired.
But it's not constrained to only work with "Web requests"; Anders links to a Google developer doc that says this:
It's deliberately generic so it can be used by other web standards and JavaScript libraries.
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 the while (true)
loop in tryUntilSuccessful
(soon to be renamed to tryFetch
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.