mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-24 13:51:56 +03:00
2c49c774af
Co-authored-by: Himself65 <himself65@outlook.com> |
||
---|---|---|
.. | ||
benchmark | ||
src | ||
package.json | ||
README.md | ||
tsconfig.json | ||
tsconfig.node.json | ||
vite.config.ts |
@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);
}
});