Skip to content

onDataChanged callback #2911

Answered by TkDodo
phatmann asked this question in Ideas
Nov 11, 2021 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

I agree with this - let’s include that in the v4 plan.

Follow up question: since this is a callback on observer level, would this callback also be called when data changes for the observer because it was read from the cache?
For example, many people use onSuccess to put the data into local state or react context. While this is not really necessary, you can still do it. However, if you combine this approach with a high staleTime, if the query key changes, you’ll get no background refetch - just the data from the cache. So onSuccess is also not called, which puts you out of sync.
An onDataChanged callback could solve that, conceptually becoming an effect with data as dependency. What do you…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@phatmann
Comment options

@TkDodo
Comment options

@matthewdavi
Comment options

@TkDodo
Comment options

Answer selected by phatmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants