Posted on Leave a comment

Optimistic updates

It’s a cool UX trick I learned recently makes applications exponentially responsive. Traditionally, when we make an async API call or something similar (to perform a time-taking operation) we show a spinner (or a loading message) to indicate to the user that something is going on in the background and that they should wait a bit before the final results. Although now widely accepted, this approach sometimes creates ‘blocking’ experiences especially when used extensively. You do not want to give an impression to your users that your application is completely dumb on its own and needs to fetch data from the all-knowing server all the time.

Optimistic updates is a strategy where you ‘optimistically’ assume that your time-taking operations will always succeed. So, instead of making users wait or showing a loader, you show the final results (when you can) right away!

Eg. On click of an item’s delete button just instantly remove the item from UI and perform the actual (server-side) delete operation in the background. The same goes for adding a new item, and so on. This will create a slick and snappy user experience that your users will love. If a background operation does fail, perhaps undo the change in UI and show a relevant error message to the user.

Of course, this strategy isn’t perfect. But it’s cool, for sure. I must have seen it at least half a dozen times before but officially learned it in this beautiful Redux course on Pluralsight by the awesome Cory House.

Check my commit to see how optimistic deletion can be implemented in a React-Redux application.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.