4 ms·
Pls excuse my complete ignorance. I'm a complete noob trying to learn web development. Why would I use this over POST and server side update db or websockets?
by throw_away90210 3y ago
Pls excuse my complete ignorance. I'm a complete noob trying to learn web development. Why would I use this over POST and server side update db or websockets?
- jitl 3y agoI’d suggest Triplit if you want to make a rich web app similar to Notion. Under the hood this thing is doing POST and websocket subscriptions. You can skip all the manual work to wire up optimistic updates, subscription, local storage, pending transaction queue by adopting someone else’s implementation. Also after doing it enough times, adding a POST endpoint per record type in your app to create/read/update/delete that type gets old.
- matlin 3y agoExactly this ^
- mainguy 3y agoI don't 100% know in the case of triplit, but pouchdb does what you describe for "free" (i.e. you don't need to code it). firebase uses a websocket, pouch uses (I believe) long polling.
- matlin 3y agojitl'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.