4 ms·
jitl's comment summarizes it well and I'd add that if you're building a highly interactive app (especially on mobile), you can't wait for network after each act
by matlin 3y ago
jitl's comment summarizes it well and I'd add that if you're building a highly interactive app (especially on mobile), you can't wait for network after each action before showing feedback to the user. If you do your app will feel janky and broken. So the solution is to show what you "optimistically" expect to happen in the UI before your request has even reached the server so each interaction feels instant. E.g. if you like Tweet in the app, it'll show a heart even if you're not connected to the internet and then in the background once it has a connection it'll sync up all of the pending request.
This, however, can become tricky to implement and really hard to maintain as you add more features.
So Triplit does this all for you automatically with the mental model that your database queries automatically update when any data changes happen even if you're offline. Triplit takes care of reconciling this whether the request succeeds on the server and with concurrent changes from other users.