automerge / automerge-repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PatchCallback Signature

acurrieclark opened this issue · comments

In automerge the PatchCallback has been recently updated so that the PatchInfo parameter includes a source property.

At the moment, the patch information is returned to the user as below:

this.emit("patch", { handle: this, patches, before, after }),

Can I propose that we adopt a similar signature to that of the PatchCallback?

const doc = A.init<T>({
  patchCallback: (patches, pathInfo) =>
    this.emit("patch", { handle: this, patches, patchInfo }),
})

This is, of course, breaking, but the (non-breaking) alternative would be to add a new property each time the automerge PatchInfo is added to.

I agree being consistent is important and we're pre 1.0 so let's just do it and make sure it pops up in the release notes. Anyone using Typescript should be okay at least :)