Replies: 1 comment
-
not sure what the use-case is for working with observers directly? when you clear the cache, active observers are not informed about those changes. I usually don’t recommend clearing the cache while there are active queries. However, when an observer receives an update e.g. because
yeah that can’t work because the new query doesn’t know anything about the old observer. I don’t think this is supported.
the observer hasn’t been “removed”, you removed the query it was observing, it sounds like the observer is still there? Really curious what you are trying to achieve with all that because it sounds way too low level for an application. If you just |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a question regarding the relationship between QueryObserver and queryCache.clear() in React Query.
I created a
new QueryObserver
and subscribed to it using thesubscribe
method.I then called queryCache.clear() to remove all cache.
After that, I updated the query data using setQueryData, but I noticed that the existing observer did not emit the new data.
So I created another
new QueryObserver
and subscribed again, which worked as expected.However, I later found that the original observer (which had already been "removed") emitted the old cached data once the staleTime of 10 minutes passed.
Questions:
Thanks in advance for the clarification!
Beta Was this translation helpful? Give feedback.
All reactions