Replies: 1 comment 1 reply
-
Is your client relying on the server for the ydoc initialization (meaning the client has no autonomy to initialize the ydoc if it is offline)? If so you could hook into the lifecycle of the Hocuspocus server to, upon loading a document, check if it could be populated with data from some other source before returning the doc to the client. If your client can initialize the doc offline it gets a bit trickier. I'm not aware of a general recommended pattern to implement this. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, could someone help me to find better solution for my situation?
I have a React app where a user is editing a form and it's fields are being synchronised via yjs with server. On the server side Hocuspocus handles document updates and saves document state to SQLite via extension.
I'm trying to figure out at which point can I load initial data for a document from the other database? Do I understand correctly that I have to listen to request from the client on the server side, which asks to create a new document. Then on the server side I create connection to Hocuspocus Server using HocuspocusProvider, check if a document exists and if not, then fetch data from a DB, create new document and populate it with data from DB.
If this approach is correct, than how do I know if a particular document exists in SQLite and Hocuspocus will not override data stored in SQLite with given one from the other DB?
Beta Was this translation helpful? Give feedback.
All reactions