Replies: 1 comment
-
That sounds a bit confusing. An optimistic update (ie Can you show the code you're trying to use here? |
Beta Was this translation helpful? Give feedback.
0 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.
-
I’m having trouble implementing optimistic updates correctly.
I have a chat app that polls the server every 10 seconds to check for new messages. When new data is available, I invalidate the cache tags for both the messenger and the conversation so they can fetch the latest data.
When I send a message, I perform an optimistic update so the message appears immediately in the conversation. Once the request succeeds, I replace the optimistic message with the actual response from the server.
This works fine — except when an optimistic update happens at the same time the conversation data is invalidated by the polling process. In that case, the optimistic message never appears in the chat because the invalidation triggers a refetch before the optimistic update is applied.
Is there any way to add the optimistic update also during cache invalidation?
Beta Was this translation helpful? Give feedback.
All reactions