Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) => {
this.queryBackend({ type: 'MaterializeMsg', history, id }, (msg) => {
const doc = automerge_1.Frontend.init({ deferActorId: true });
cb(automerge_1.Frontend.applyPatch(doc, msg.patch));
});
};
this.queryBackend({ type: 'MaterializeMsg', history, id }, (msg) => {
const doc = automerge_1.Frontend.init({ deferActorId: true });
cb(automerge_1.Frontend.applyPatch(doc, msg.patch));
});
};
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,
});
}
});
}