Break ground on document "persistence"

This commit is contained in:
2025-08-22 22:18:59 -07:00
parent e34898a1a6
commit f3d4cd72ac
2 changed files with 23 additions and 2 deletions
+15
View File
@@ -0,0 +1,15 @@
import * as Y from 'yjs';
const fakeStore = new Map<string, Uint8Array[]>();
export function syncDoc(id: string, doc: Y.Doc) {
const updates = fakeStore.get(id) ?? [];
fakeStore.set(id, updates);
for (const update of updates) {
Y.applyUpdate(doc, update);
}
doc.on('update', (update: Uint8Array) => {
updates.push(update);
});
}