Replies: 1 comment 2 replies
-
@tannerlinsley - Would love to hear your thoughts, specially about this being part of the API. 👨🏫 |
Beta Was this translation helpful? Give feedback.
2 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.
-
Hi everybody.
Been trying to look for a related discussion but couldn't find anything.
I was wondering if there's a built-in ability to differentiate between changes coming from Mutate operations to changes coming from Server "refresh" (meaning a new data was returned while revalidating).
This seems to me something quite trivial that should've been part of the API and common usage patterns.
Basically my usage is:
I have a page with several editable components, that can potentially be edited by multiple users at the same time.
Because the changes and multi-editing for this page are not that frequent, I want to load it immediately from the cached data and ignore the entire
isFetching
mechanism, since I don't need to introduce loading mechanism there.When I first load it and fetch the entity with
useQuery
I parse the data into a relevant object.When I update a component, I use
mutate
and update the data locally, triggering a new process of parsing the data and resulting in a new object and new reference (which is a good thing).When
useQuery
revalidates the data and a new data arrives, this is a fresh data from the server and I want to display a fake 1 second loader with the message "syncing from server" or something similar, only in the components that changed.This way, I get to have a seamless experience and only interfere the user's experience when needed and in a minimal way.
The problem is that I cannot differentiate the data changes between the two potential sources easily.
The only solution I see right now is to set some boolean state "hasMutated" on mutate success and then when
useQuery
data changes check this bool and act accordingly (and obviously turn it off afterwards).Does this sound like a good workaround solution?
My expectations from the library would've been to have some boolean on
useQuery
, similar toisFetching
which helps you to identify this (e.gisRefreshedData
boolean)Thank you kindly and hope this entire thing makes sense. 😅
Beta Was this translation helpful? Give feedback.
All reactions