AFFiNE/packages/y-indexeddb
2023-06-02 13:02:48 +08: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
.gitignore build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00:00
package.json v0.7.0-canary.8 2023-06-02 13:02:48 +08:00
README.md refactor: workspace provider (#2218) 2023-05-03 18:16:22 -05:00
tsconfig.json build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00:00
tsconfig.node.json build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00: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);
  }
});