Optimistic Update conflict
I'm working on a 'favorites' feature for products, where you can like or unlike an item. When you like something, it shows up as liked right away on your screen because I save it locally. If you unlike it, it disappears from your local favorites immediately.
The tricky part is when you quickly like and then unlike an item. Your screen shows it as unliked, which is correct. But, the 'like' action is still being processed by the server. If the server confirms the 'like' after you've already unliked it, the item flashes as 'liked' for a moment before going back to 'unliked'. It's a bit of a visual glitch.
Is there a good way to stop this from happening and make sure the screen always shows what you actually last did, even if the server is a bit slow to catch up?
As far I can see need client side convex package adjustments to make this happen. This feature is needed by a lot of production ready apps like Instagram for example.
1 Reply
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!