AFFiNE/packages/y-indexeddb
2023-05-09 01:35:49 -05:00
..
benchmark perf(y-indexeddb): improve boost and loading time (#1879) 2023-04-11 17:29:44 -05:00
src feat(y-indexeddb): add connected (#2208) 2023-05-05 03:42:49 +00:00
package.json chore: bump version (#2279) 2023-05-09 01:35:49 -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);
  }
});