pluv-io / pluv

Multi-platform, type-safe realtime packages
https://pluv.io
MIT License
57 stars 2 forks source link

feat: Yjs Subdocument support #503

Open Alex-ray opened 9 months ago

Alex-ray commented 9 months ago

Hey @leedavidcs I was wondering if you've built out support for Yjs subdocuments through shared types?

Great project btw, i'm really looking forward to version 1.0!

leedavidcs commented 9 months ago

Hi @Alex-ray! Thanks for the feature request!

This is not something I've looked into or have considered unfortunately :slightly_frowning_face:. You could possibly try just adding the subdocument in your storage and see whether it just happens to work? Likely, you would need to manage your subdocument outside of pluv.io with another provider, so the experience may not be ideal.

Maybe pseudocode? :sweat_smile::

import { y } from "@pluv/react";
import * as Y from "yjs";

createRoomBundle({
    initialStorage: () => ({
        folders: y.object({
            mySubDoc: new Y.Doc(/* ... */)
        }),
    }),
});

const [, sharedType] = usePluvStorage("folders");

const mySubDoc = sharedType.get("mySubDoc");
   // ^? Y.Doc probably?

// Maybe usable? ¯\_(ツ)_/¯

Let me know if you happen to arrive at any successes or discoveries around this.