ivan-topp / y-socket.io

Socket IO Connector for Yjs (Inspired by y-websocket)
MIT License
66 stars 14 forks source link

Is there a way to create a document on the server via API instead of through a socket call? #5

Open vincesp opened 1 year ago

vincesp commented 1 year ago

There are use cases where the server is the master of the documents. Is there a better way to have documents created by the server than opening a socket to self, i.e., running a client on the server?

y-websocket has getYDoc() to create new documents on the server.

Couldn't y-socket.io somehow export initDocument() as well?

midsplit commented 1 year ago

I think the best way to do this is to create a document in your database with an initial value through a POST request and open that document from the backend.

I've managed to get a Plate.js + Slate-yjs + y-socket.io setup to work using the 'document-update' and the 'document-loaded' event handlers from this library, and the app is 100% server-driven. If you're trying to get a similar setup, I'd be happy to give you some pointers!

odufuwa-segun commented 4 months ago

hi @midsplit, I working on something similar, if you don't mind could you share some pointers on how you got this working?