SvelteStack / svelte-query

Performant and powerful remote data synchronization for Svelte
https://sveltequery.vercel.app
MIT License
814 stars 31 forks source link

How would I go about refetching a query if another query comes back changed? #18

Closed saturnonearth closed 3 years ago

saturnonearth commented 3 years ago

Basically, I have a query that I want to go and check a timestamp, and if that timestamp has changed, I want to refetch or fetch the actual data I need. I want to do this to prevent repeatedly fetching large amounts of data.

Is this possible? If so, how would I go about doing this? Thanks.

amen-souissi commented 3 years ago

Hello and thanks :)

Since query keys uniquely describe the data they are fetching, they should include any variables you use in your query function that change. I think that the timestamp should be included in your queryKeys. Please see this https://sveltequery.vercel.app/guides/query-keys

saturnonearth commented 3 years ago

Hi there, I figured it out, thanks!