Open aaaidan opened 3 years ago
Hi @aaaidan -- happy to help. Here's a link to some demo code that I'm working on. It's rather undocumented, so please ask any and every question that comes to mind and we'll put the answers into the README / improve the code as we go. Sound good?
Just to orient you, the automerge-store
and shared-worker
are where the meat of things are. What you'll see is a system that communicates between several tabs using BroadcastChannel and each tab gets a Worker thread to run the CRDT in. This is attempting to simulate a P2P system and you'll really want to communicate via some kind of a server but I wanted to start with something self-contained as a reference.
Each change is written to localStorage as it happens and is compacted every 100 changes to reduce storage size. (That's DB.js's job.)
Although it's written in Svelte there's basically nothing svelte-specific here if you (as I expect) are using React you should find it straightforward to just lift the bits you need. If not, let me know and we can sort it out together. Good luck and don't hesitate to ask questions and/or muse out loud about confusing bits.
Thank you so much @pvh! Picking through it now. 👍
(I'm new to automerge (and crdt in general) please be gentle! 😅)
I'm finding it difficult to get the "1.0" sync protocol working. No errors, but also no syncing. I must be doing something wrong. I'm on the latest (preview-4).
Sync doc are nice and detailed, but I would find it even more helpful with some "live" demo code, including simulated data transport. The current code snippets seem mostly indicative; they're not meant to be run as is.
Pushpin doesn't seem to use the sync protocol (I can't find
generateSyncMessage
anywhere in the code). Am I missing an existing demo?The code in the sync tests seem pretty informative, perhaps that could be adapted?