AFFiNE/packages/y-indexeddb
2023-06-13 14:13:38 +08:00
..
benchmark perf(y-indexeddb): improve boost and loading time (#1879) 2023-04-11 17:29:44 -05:00
src build: enhance tsconfig type check (#2732) 2023-06-09 01:42:58 +08:00
.gitignore build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00:00
package.json v0.7.0-canary.13 2023-06-13 14:13:38 +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 chore: bump typescript to 5.1.3 (#2735) 2023-06-09 11:42:54 +08: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);
  }
});