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
Cancelling in-flight fetch requests with AbortController/AbortSignal #1917
Comments
const abortableFetch = (url, opts) => {
const controller = new AbortController();
const signal = controller.signal;
const promise = fetch(url, {
...opts,
signal,
})
promise[CANCEL] = () => controller.abort()
return promise
} |
So, you would see redux-saga automatically try to call promise.cancel() (if present) on |
Yes, kinda. This is already supported. |
@slorber this can be closed, right? |
But this does not work if one uses async await. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, for a blog post I'm working on about race conditions, where I mention
takeLatest
, I was wondering how we could add support for in-flight request cancellations to Redux-saga in a generic way.My saga is a bit rusty, but I wrote this pseudo code.
What do you think about supporting officially some helpers for in-flight request cancellation?
Note redux-observable/rxjs already has some more advanced discussions/implementations regarding this feature: ReactiveX/rxjs#3122
https://github.com/ReactiveX/rxjs/blob/1dc09e9f21780645063407d6670ee2f5e3e399f5/src/internal/observable/dom/fetch.ts
The text was updated successfully, but these errors were encountered: