Subdoc Support
Hi naporin0624,
Any plans to support subdocuments? If so, could you outline a potential implementation approach? I’d be happy to assist in development.
^^^
Subdoc synchronization should work by creating a WebSocketProvider instance for each subdoc.guid. Since DurableObjects make it easy to scale websocket servers by ID, I think you can handle subdoc connections the same way as doc connections. (ref: https://docs.yjs.dev/api/subdocuments)
doc.on('subdocs', ({ loaded }) => {
loaded.forEach(subdoc => {
new WebrtcProvider(subdoc.guid, subdoc)
})
})
doc.getSubdocs() // Get the Set<Y.Doc> of all subdocuments
If this works well, I'd be happy if you could create a PR to add it as an example.
If the increase in websocket connections per subdoc is a concern, the approach discussed here might be useful: https://discuss.yjs.dev/t/multiple-room-sync-subdocument/403/3