Maya· 2 h
Finished the trail run before sunrise.
Also called: optimistic UI, instant update, update first, confirm later.
The screen shows the result of your action right away, before the server has confirmed it. If the server then says no, the screen goes back to how it was and tells you it didn't work.
Tap the heart: it fills at once, and the server answers 1.2 s later. Turn on “Server fails” to see the like roll back.
Say it in a prompt
When the user taps Like, fill the heart and add 1 to the count immediately, then send POST /posts/:id/like. If the request fails or takes longer than 5 s, put the heart and the count back to what they were and show "Couldn't save your like" under the post for 4 s.