How to use the automerge/backend.init 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 / index.ts View on Github external
createDocument(keys: Keys): BackendManager {
    const docId = Base58.encode(keys.publicKey)
    log("Create", docId)
    const doc = new BackendManager(this, docId, Backend.init())

    this.docs.set(docId, doc)

    this.initFeed(doc, keys)

    return doc
  }
github automerge / hypermerge / src / DocBackend.ts View on Github external
constructor(core: RepoBackend, id: string) {
    this.repo = core;
    this.id = id;

    this.back = Backend.init();
    this.actorId = id;
    this.subscribeToRemoteChanges();
    this.subscribeToLocalChanges();
    const history = (this.back as any).getIn(["opSet", "history"]).size;
    this.repo.toFrontend.push({
      type: "ReadyMsg",
      id: this.id,
      actorId: id,
      history
    });
  }