How to use the automerge/frontend.change function in automerge

To help you get started, we’ve selected a few automerge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inkandswitch / capstone / src / node_modules / hypermerge / frontend.ts View on Github external
this.changeQ.subscribe(fn => {
      const doc = Frontend.change(this.front, fn)
      const request = Frontend.getRequests(doc).pop()
      this.front = doc
      log(
        `change complete doc=${this.docId} seq=${
          request ? request.seq : "null"
        }`,
      )
      if (request) {
        this.emit("doc", this.front)
        this.emit("request", request)
      }
    })
  }
github inkandswitch / capstone / src / modules / hypermerge / frontend.js View on Github external
this.pFront.then(() => {
      this._front = Frontend.change(this._front, fn)
      this.emit("doc",this._front)
      this.emit("requests", Frontend.getRequests(this._front))
    })
  }
github inkandswitch / capstone / src / data / StoreEntry.ts View on Github external
change = (cfn: ChangeFn) => {
    if (!this.doc) throw new Error("Cannot call change before doc has loaded.")

    this.doc = Automerge.change(this.doc, cfn)

    const requests = Automerge.getRequests(this.doc)
    this.port.postMessage(requests)
    this.listeners.forEach(fn => fn(this.doc))
  }