Optimistic updates, or lying well
Showing the result before it is confirmed, and cleaning up when you were wrong.
When you tap a heart icon and it fills instantly, the server has almost certainly not confirmed anything yet. The interface assumed success and drew it. This is an optimistic update, and it is why good apps feel instant despite the same network as everyone else.
- Act
Update the screen immediately, assuming success. - Send
Tell the server in the background. - Confirm
Usually fine. Nothing visible changes. - Or revert
It failed. Put it back and say so.
The honest middle ground is often better than either extreme: show the change immediately, but mark it as pending, slightly faded, with a small indicator. The user gets instant feedback and an accurate picture, and a failure is a change of state rather than a contradiction.
What to remember
- Optimistic updates trade accuracy for perceived speed.
- Only use them where failure is rare and reverting is harmless.
- The revert path is the one that will be untested. Test it deliberately.
Terms in this lesson
Show field notes toggles a search param the loader reads. With it off, the slow promise is never created, so nothing streams.