Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Cancelation #1933

Closed
shuding opened this issue Apr 17, 2022 · 3 comments
Closed

Cancelation #1933

shuding opened this issue Apr 17, 2022 · 3 comments
Labels

Comments

@shuding
Copy link
Member

shuding commented Apr 17, 2022

⚠️ This proposal isn't finalized yet.

An abort signal will always be passed to fetcher via the option:

useSWR('/api', (url, { signal }) => {
  return fetch(url, { signal }).then(res => res.json())
})

And SWR will abort the signal when the request is discarded and the result is no longer needed. After aborted, SWR ignores the AbortError thrown.

@shuding shuding added the feature request New feature or request label Apr 17, 2022
@shuding shuding added the RFC label Apr 29, 2022
@700software
Copy link

This is amazing! Elegant and in spirit with SWR's simplicity.

It would cause aborts to happen in applications where none were happening before. But is it a breaking change? I think not.

@l-mbert
Copy link

l-mbert commented Aug 13, 2022

Looks good!
Maybe add a new configurarion option for People who don't want it?

@CaptainPants
Copy link

I have given implementation of this a go in the above PR if anyone is competent to have a look and give any feedback? Cheers.

@vercel vercel locked and limited conversation to collaborators Dec 20, 2022
@koba04 koba04 converted this issue into discussion #2312 Dec 20, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

5 participants