How do apps Like Notion handle updating the text content so often?

What I mean is, you can click into a field, type something, click out, and it's automatically saved. I'd like to implement something like this in my own App and am wondering how is this done? Is an API request sent to the backend every time a user clicks out of the field?
11 Replies
McDusty
McDusty2y ago
I would bet they are using web sockets to do a stream of data. As you type it’s sending it. There is probably a state machine or something keeping track of the user is in edit mode or in view mode.
zio_
zio_2y ago
Gotcha, that makes sense. Thanks!
McDusty
McDusty2y ago
I could be wrong on that. But I think they allow multiple people to edit the same doc at the same time. So that’s likely how they achieve it.
Samathingamajig
(check the network tab)
benten
benten2y ago
^ I've implemented something similar by debouncing POST requests web-socket would probably be necessary for collaboration though
Samathingamajig
or just a lot of POST and polling lmao
benten
benten2y ago
Yeah. Probably depends on the field For documents I use websockets + y.js, but for the fields I just post and poll Doesn't really matter if someone changing the name of a doc gets overwritten by a simultaneous change
iDarkLightning
I'm fairly certain that they have a sync engine
zio_
zio_2y ago
What’s a sync engine?
Samathingamajig
a system used to sync changes
zio_
zio_2y ago
Lol I see
Want results from more Discord servers?
Add your server