AFFiNE/packages/y-indexeddb
2023-05-04 18:50:20 -05:00
..
benchmark perf(y-indexeddb): improve boost and loading time (#1879) 2023-04-11 17:29:44 -05:00
src feat(y-indexeddb): cleanup (#2207) 2023-05-04 20:25:58 +00:00
package.json v0.5.4-canary.22 2023-05-04 18:50:20 -05:00
README.md refactor: workspace provider (#2218) 2023-05-03 18:16:22 -05:00
tsconfig.json refactor: remove y-indexeddb (#1771) 2023-04-02 02:57:50 -05:00
tsconfig.node.json refactor: remove y-indexeddb (#1771) 2023-04-02 02:57:50 -05:00
vite.config.ts build(y-indexeddb): fix vite config 2023-04-20 18:08:33 -05:00

@toeverything/y-indexeddb

Usage

import { createIndexedDBProvider, downloadBinary } from '@toeverything/y-indexeddb';
import * as Y from 'yjs';
const yDoc = new Y.Doc();

// sync yDoc with indexedDB
const provider = createIndexedDBProvider('docName', yDoc);
provider.connect();
await provider.whenSynced.then(() => {
  console.log('synced');
  provider.disconnect();
});

// dowload binary data from indexedDB for once
downloadBinary('docName').then(blob => {
  if (blob !== false) {
    Y.applyUpdate(yDoc, blob);
  }
});