Skip to content
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

Force refresh for useAsyncData and useFetch #14746

Closed
pi0 opened this issue Aug 30, 2022 · 1 comment · Fixed by nuxt/framework#7864
Closed

Force refresh for useAsyncData and useFetch #14746

pi0 opened this issue Aug 30, 2022 · 1 comment · Fixed by nuxt/framework#7864

Comments

@pi0
Copy link
Member

pi0 commented Aug 30, 2022

(from various references and nuxt/framework#5738 by @OhB00)

We had the ability to force refresh asyncData state using refresh(true). It had been removed in nuxt/framework#699 to make refresh API forward compatible using an object syntax ({ force: true }) but also probably reimplement.

The main issue with refreshing while another promise is running is that we are not canceling the previous one. (and there is no standard spec for cancelable promises).

For useFetch, it is completely doable and we can use cancelation tokens to automatically cancel previous ones.

For useAsyncData as handler function that runs promise is black box, we need to find a way to reject stalled promise when it resolved and keep it in an alternative place for asyncDatas.

@pi0 pi0 changed the title Force refresh for useAsyncData Force refresh for useAsyncData and useFetch Aug 30, 2022
@robinsimonklein
Copy link

robinsimonklein commented Sep 1, 2022

Hi @pi0 ,

I'm using the refresh method from useAsyncData for an autocomplete input usage. As I need to fire refresh on every user input, which can happen before last refresh has finished, I need to force the refresh.
Is there still a way to achieve this ?

I tried with refresh(true) (as said in docs) and refresh({force: true}) but neither of them seem to work.

Thanks in advance !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants