Description
Optimistic update is when you show the success result, before you get a response back from the API
?
Reach for when
You want the user to not feel any load and can handle the conflict in the backend.
Pseudocode
1. Shapshot previous state
2. Optimistrically udpate cache
3. on Error rollback on settle refetch for truth
A few versions include:
- Last write wins - the user who made the update last will win conflict.
- Transaction-based model - denounce updates and send it as a chunk where users explicitly pull change (git).
- Version control with compensation - check the version number on the users document if they deffer, then merge changes