ghard1314
Multiple optimistic updates and old data from refetches
I think you were originally right about
cancel
stopping refetches from invalidate
but thats not really helping you here when you have back to back mutations. Lets look at a quick timeline of whats happening here when you make 2 back to back delete mutations before the first one settles.
8 replies
Creating inner context for AWS Lambda Context Options
If your goal is to tell if a user is present or not, you should do this through middleware.
Here are the docs you want for this probabily
https://trpc.io/docs/server/server-side-calls
5 replies
Multiple optimistic updates and old data from refetches
Another idea would be to put the refetch on a debounce that gets renewed anytime another delete action is taken. This way you still get fresh data eventually that should match your local cache, but it wont override many fast changes
8 replies
Multiple optimistic updates and old data from refetches
When you call
invalidate
that triggers a refetch from the server which is going to override any optimistic updates you made to your cache like you are seeing. There may be some ways to make this play nicely with your existing optimistic update, but my question is:
do you really need to refetch data?
Unless your expecting this data to change from another source beside this users interactions, there shouldnt really be a need to get fresh data from the server right?8 replies