4

So, I found about the discussion about the concept optimistic update and this is the thread:

what is `optimistic updates` in front-end development

My question is :

What if the user clicks the upvote and he thinks he is done, and he just closes the tab/window. But maybe 2 days later, he finds out his vote never succeeds. He either gets pissed off, or he thinks the voting result is cooked.

I don't understand why a more responsive user experience triumphs a true-y result ?

Or, a better question is : when do we need optimistic update ?

Yumin Gui
  • 389
  • 3
  • 9
  • 1
    A solution to that would be to prompt the user with an alert once he tries to close the tab if the background process is still ongoing that way even if he says yes he would be responsible for his decision. – Nader Zouaoui Mar 31 '20 at 19:06

2 Answers2

4

So I think of it like this.. applications like Facebook, instagram and all what has the experience of interacting while scrolling. When you're scrolling and press like, once you see it in the UI, you keep on scrolling, you don't usually go back and check even if the request fails.. but if it wasn't optimistic, you press like and it gives you nothing until your request succeeds, this urges the user to stop the actual action of scrolling and keep on pressing until he's satisfied.

also, statistically speaking, optimistic comes from the optimism that a certain action has a higher chance of success, actions like "like, love, upvote, etc". so it makes more sense not to wait for all these responses since 90% of time it's going to land.

2

Your question has a problem in itself, the point is that the user action will be delivered to the server immediately, but since that is a asynchronous task (side effect) - the client (redux store) doesn't care about the response and immediately sets the upvote in the store. Now potentially there will be an error with the upvote, but our application doesn't care, because we are using an optimistic update on a non-critical feature.

So even if the browser is closed, the upvote will still be registered server side and the next time the user enters your page, he will see his upvote. The only time untruthy information is shown, is in the case of an error. The idea is that there are seldom any error cases and even if there are error cases, the feature is not critical and the error is therefore not important and should not have an impact on the users flow on our website.

Ali Nasserzadeh
  • 1,365
  • 7
  • 15
  • Thanks. This is the answer I kind of expect. I do understand the merit of `optimistic update`, and I will use it in some non-critical features, such as upvote or something. I will `NOT` use it in a `reply` or `send message` or `contact us`, because if the message is lost, we are not able to retrieve it. – Yumin Gui Mar 31 '20 at 19:32