I would like to understand how to better think in the Yjs 'way’
I’m excited to understand Yjs better as I see how it enables me to bring collaboration to my app. Amazing. I managed to get a basic collaborative editor up and running over WebRTC in 30 mins with Quill and cursors, which is a fantastic testimony as to how good this library is, great work!
Currently I’m using a very standard approach: store document in Firestore, retrieve for editing, save when done (I’m using Quill and am storing Delta objects).
Using Yjs, I believe it might be important to rethink the way document data is persisted. There’s been a few discussions on how to initialise a Ydoc from an existing, standard JSON object. Perhaps this is the wrong approach?
’Traditional’ thinking approach:
- Fetch stored JSON object
- Set YDoc initial content from JSON object ← this presents problems, which client initialises the Ydoc?
’Yjs thinking’ approach?:
- Create new JSON object, create Ydoc, update DB with Ydoc content
- Retrieve Ydoc update content for editing, initialise with this value ← each client will get latest update and then sync, no problem
- Long term storage may require a doc → Ydoc conversion prior to editing, and a Ydoc → doc conversion before saving. But maybe this is traditional thinking and wrong.
’Concepts’ Documentation Addition
Lastly, may I humbly suggest it would be good to add a page to the docs which describes the ‘Yjs way’ of thinking if that’s even a thing. I think new users would benefit from this. As trying to learn RxJS required some re-thinking, perhaps using Yjs is the same? I’m very happy to contribute once my understanding is solid.
Apologies if I’ve missed existing documentation that explain this!