Replies: 2 comments 1 reply
-
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.
-
Here is a video, as you can see it works fine for the first message, but when i try to add an optimistic update while fetching the newest conversation data (you can see a blue skeleton at the top while fetching) than the message does not appear, when the fetching is over and then i send a message it works fine (as you can see with the last message again). trim.F6500748-BB5F-46E6-98D3-46708D1589EB.MOV |
Beta Was this translation helpful? Give feedback.
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