@toeverything/y-indexeddb

0.10.0-canary.9 • Public • Published

@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);
  }
});

LICENSE

MIT

Package Sidebar

Install

npm i @toeverything/y-indexeddb

Weekly Downloads

3,254

Version

0.10.0-canary.9

License

MIT

Unpacked Size

105 kB

Total Files

19

Last publish

Collaborators

  • doodlewind
  • buildblocks