-
Using |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 17 replies
-
I am wondering the same thing, this would be very powerful if its possible. However from reading the docs it seems that it is not. I assumed subscribing to an observer with
if I am correct what is the reasoning for this? |
Beta Was this translation helpful? Give feedback.
-
I think you would just do |
Beta Was this translation helpful? Give feedback.
-
You can use
Now your component will subscribe to the changes in queryCache and item will be updated. |
Beta Was this translation helpful? Give feedback.
-
You can use |
Beta Was this translation helpful? Give feedback.
-
queryClient.getQueryCache().subscribe((queryCacheNotifyEvent) => {
if (!queryCacheNotifyEvent) {
return;
}
console.log(queryCacheNotifyEvent);
}); |
Beta Was this translation helpful? Give feedback.
-
I think QueryObserver can help you const observer = new QueryObserver(queryClient, { queryKey: ['posts'] }) const unsubscribe = observer.subscribe(result => { |
Beta Was this translation helpful? Give feedback.
-
Pass the key but not the function like this:
|
Beta Was this translation helpful? Give feedback.
-
I wrote a hook for this:
Basically you just have to set the |
Beta Was this translation helpful? Give feedback.
-
I was facing the same problem, here's what I did and it's working fine, as expected: To listen to the query:
|
Beta Was this translation helpful? Give feedback.
I think you would just do
useQuery
again in that other component? Or am I missing something here?