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
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.
Gotcha, that makes sense. Thanks!
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.
(check the network tab)
^
I've implemented something similar by debouncing POST requests
web-socket would probably be necessary for collaboration though
or just a lot of POST and polling lmao
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
I'm fairly certain that they have a sync engine
What’s a sync engine?
a system used to sync changes
Lol I see