refactor: workspace provider (#2218)

This commit is contained in:
Himself65 authored and GitHub committed 2023-05-03 18:16:22 -05:00
1 parent ec39c23fb7
commit 9096ac2960
18 files changed
+377 -255

No files matched your search

+9 -3
View File
@@ -1,18 +1,24 @@
# @toeverything/y-indexeddb
> This package haven't been published yet.
## Usage
```ts
import { createIndexedDBProvider } from '@toeverything/y-indexeddb';
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);
}
});
```