Replies: 1 comment 5 replies
-
I think you would have to set Otherwise, maybe you can keep the |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I'm building a library for Firebase (react-query-firebase) & there's a logic flow I'm not sure how to handle.
When working with Cloud Firestore, we can subscribe to realtime updates. In basic form, you can do something like this:
Behind the scenes, a subscription is created using the Firebase SDK (code).
Now, since the data is updating the query cache manually anytime data is updated, I am setting
staleTime
toInfinity
. This ensures that any new hooks using the same query key don't create a new realtime subscription (since there is no point). This works fine.The issue is when a
cacheTime
exists (which it does by default). If all usages of a hook are no longer in use, I unsubcribe from Firestore realtime updates.If the hook is reused again whilst the data is still in the cache, the "queryFn" never fires again, meaning no more updates.
Question
How can I go about saying "this data while in use is never stale, however if a query key is used and cached data exists, I want to trigger the 'queryFn' again".
Beta Was this translation helpful? Give feedback.
All reactions