Skip to content

get change message(s) from Automerge.getChanges() #534

Open
@michaelpalumbo

Description

TLDR: Is it possible to get filter changes returned by getChanges() according to the message in the changeOption? How is this done?

I have change messages assigned to each of the possible edits in my app, i.e.

// message 'update position'
this.document = Automerge.change(this.document, 'update position', doc => {
  doc[posID].position = payload[1]
}) 

// and message 'add cable':
this.document = Automerge.change(this.document, 'add cable', doc => {
  for(let i=0; i<doc[srcID].outputs.length; i++){
    // find the output in the doc matching the cable's src
    if(doc[srcID].outputs[i].name == srcJack){
      if(!doc[srcID].outputs[i].connections[destID]){
        doc[srcID].outputs[i].connections[destID] = {}
      }
      doc[srcID].outputs[i].connections[destID][destJack] = cableType
    }
  }     
})

These two document changes are handled quite differently in the app: the first one results in changes to a visual scene, while the second results in changes to both visuals and what is hear in the audio output.

I recently implemented the Automerge Sync protocol, which is working great. Each time a syncMessage has been received and processed, I want to run Automerge.getChanges() and get the change message per each change so that I can trigger the additional steps related to each edit type.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions