Yjs
@homeostate/crdt-yjs
Yjs CRDT backend for @homeostate/core
Warning
Draft / placeholder release. 0.0.0 reserves the name while the API is still
being designed. Nothing here is stable — do not depend on it yet.
Yjs backend for
@homeostate/core.
It maps the synced state onto a Y.Map (nested objects become Y.Map, arrays Y.Array,
strings Y.Text) and writes fine-grained operations derived from getChanges.
Install
npm install @homeostate/core @homeostate/crdt-yjs yjsyjs is a peer dependency.
Usage
import * as Y from "yjs";
import { createSyncEngine } from "@homeostate/core";
import { createYjsBackend } from "@homeostate/crdt-yjs";
const doc = new Y.Doc();
const engine = createSyncEngine(createYjsBackend(doc, "shared"), adapter);
engine.connect();The synced state lives in doc.getMap('shared'); a middle-of-array delete, a toggle, or a
keystroke each produce one small update.