-
Notifications
You must be signed in to change notification settings - Fork 17
[Question] How to boostrap slate with a persisted doc? #80
Comments
Hi @mdegrees, Thanks so much for those kind words 😊. To provide an initial value from the server you need to modify the y-websocket code a bit. The initial version of this repo had such an implementation you can use for inspiration: slate-yjs-example/server/server.ts Line 47 in d381d18
Sorry in advance for the quality of code in there 😅 |
@BitPhinix thank you so much for your fast response 🙏 . Looking at the implementation, it does make perfect sense. I think one way to go about it, without implementing a custom server is to use the exposed Do you see any value in keeping Yjs' binary version of the doc alongside slate's value? |
Hi @mdegrees,
If it works it's definitely the way to go, the custom WebSocket server implementation was just a hack to get things running quickly for this repo. We were slate-yjs with a custom go service to handle doc changes in prod.
Yes, definitely. If you want to allow clients to perform offline modifications you'll need the binary yjs document to be able to merge the changes. With a single service instance this is relatively easy but scaling it across multiple services comes with a lot of challenges. I really recommend https://discuss.yjs.dev. There are a lot of really smart and helpful people in there that can help you along the way :) |
Oh cool, I see. Thank you so much for the pointers. |
First of all, thank you for sharing this awesome piece of work. I managed to run the example just fine. I am trying to get it to work with persisted docs. For now, just for the sake of prototyping, I'm using y-leveldb with y-websocket.
What I can't get my head around is how to bootstrap Slate with the persisted doc. It says here
slate-yjs-example/src/Client.tsx
Line 76 in d8be483
If I've well understood, by the time the sync process is done. The client Ydoc is in complete sync with the Websocket copy. No need to fetch anything from the server. Theoretically, I should reflect the Ydoc state on Slate but I can't get it to work. Is this even the right approach? Can you point me please to any working example?
Thank you 🙏
The text was updated successfully, but these errors were encountered: