automerge / automerge-classic

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
http://automerge.org/
MIT License
14.75k stars 466 forks source link

receiveSyncMessage is not invoking patch callback #349

Closed nemanja-tosic closed 3 years ago

nemanja-tosic commented 3 years ago

Expected: patchCallback should be invoked, as the document is being patched.

nemanja-tosic commented 3 years ago

Might have jumped the proverbial gun here. Will close if i did.

ept commented 3 years ago

Hi @nemanja-tosic, if you pass a patchCallback when the document is instantiated (i.e. on Automerge.init(), Automerge.load(), Automerge.from(), or Automerge.clone()), then that callback should get called on receiveSyncMessage. I didn't include an options object for receiveSyncMessage since the function actually returns the patch as its third return value, which gives you the same information without the clumsy control flow of a callback function.