Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo code for [generate|recieve]SyncMessage #418

Open
aaaidan opened this issue Aug 1, 2021 · 3 comments
Open

Demo code for [generate|recieve]SyncMessage #418

aaaidan opened this issue Aug 1, 2021 · 3 comments

Comments

@aaaidan
Copy link

aaaidan commented Aug 1, 2021

(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?

@pvh
Copy link
Member

pvh commented Aug 1, 2021

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?

@pvh
Copy link
Member

pvh commented Aug 1, 2021

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.

@aaaidan
Copy link
Author

aaaidan commented Aug 2, 2021

Thank you so much @pvh! Picking through it now. 👍

echarles pushed a commit to datalayer-externals/automerge-classic-arch that referenced this issue Feb 16, 2023
…der_include

Expose `Vec<automerge::Change>` initialization and `automerge::AutoCommit::with_actor()` to the C API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants