mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-24 05:48:59 +08:00
7b35722288
## Features - https://github.com/toeverything/BlockSuite/pull/6737 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/6735 @pengx17 - https://github.com/toeverything/BlockSuite/pull/6740 @regischen ## Bugfix - https://github.com/toeverything/BlockSuite/pull/6744 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/6742 @doouding ## Refactor ## Misc - https://github.com/toeverything/BlockSuite/pull/6741 @fundon
@toeverything/y-indexeddb
Features
- persistence data in indexeddb
- sub-documents support
- fully TypeScript
Usage
import { createIndexedDBProvider, downloadBinary } from '@toeverything/y-indexeddb';
import * as Y from 'yjs';
const yDoc = new Y.Doc({
// we use `guid` as unique key
guid: 'my-doc',
});
// sync yDoc with indexedDB
const provider = createIndexedDBProvider(yDoc);
provider.connect();
await provider.whenSynced.then(() => {
console.log('synced');
provider.disconnect();
});
// dowload binary data from indexedDB for once
downloadBinary(yDoc.guid).then(blob => {
if (blob !== false) {
Y.applyUpdate(yDoc, blob);
}
});