How to use the automerge.Frontend 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 automerge / hypermerge / dist / DocFrontend.js View on Github external
this.setActorId = (actorId) => {
            log('setActorId', this.docId, actorId, this.mode);
            this.actorId = actorId;
            this.front = automerge_1.Frontend.setActorId(this.front, actorId);
            if (this.mode === 'read') {
                this.mode = 'write';
                this.enableWrites(); // has to be after the queue
            }
        };
        this.init = (minimumClockSatisfied, actorId, patch, history) => {
github automerge / hypermerge / dist / RepoFrontend.js View on Github external
this.queryBackend({ type: 'MaterializeMsg', history, id }, (msg) => {
                const doc = automerge_1.Frontend.init({ deferActorId: true });
                cb(automerge_1.Frontend.applyPatch(doc, msg.patch));
            });
        };
github automerge / hypermerge / dist / RepoFrontend.js View on Github external
this.queryBackend({ type: 'MaterializeMsg', history, id }, (msg) => {
                const doc = automerge_1.Frontend.init({ deferActorId: true });
                cb(automerge_1.Frontend.applyPatch(doc, msg.patch));
            });
        };
github automerge / hypermerge / dist / DocFrontend.js View on Github external
this.changeQ.subscribe((fn) => {
            const [doc, request] = automerge_1.Frontend.change(this.front, fn);
            this.front = doc;
            log(`change complete doc=${this.docId} seq=${request ? request.seq : 'null'}`);
            if (request) {
                this.updateClockChange(request);
                this.newState();
                this.repo.toBackend.push({
                    type: 'RequestMsg',
                    id: this.docId,
                    request,
                });
            }
        });
    }