Key insights
- Update the UI the instant the user acts, then sync with the server in the background — don't block on the response.
- The brain reads anything under 400ms as instant; a spinner past that threshold makes the action feel broken.
- When the request fails, roll back the UI cleanly — undo the like, restore the count, as if it never happened.
- The core bet: trust the success case (which is almost always what happens) and handle the rare failure gracefully.
- Reserve it for reversible, low-stakes actions — likes, toggles, reorders — where an occasional rollback costs nothing.
Do / Don't
- Do: Update the interface immediately, then reconcile with the real server response behind the scenes.
- Do: Roll back to the previous state the moment a request fails, so the UI never lies for long.
- Do: Apply it to reversible interactions like likes, favorites, and list reordering.
- Don't: Use it for payments, transfers, or anything you can't safely undo.
- Don't: Show a charge, booking, or confirmation before the server has actually cleared it.