How to use the yjs.IndexedDB function in yjs

To help you get started, we’ve selected a few yjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github citrusbyte / thicket / packages / thicket-webapp / src / database / index.js View on Github external
const ipfsConfig = {
  repo: 'thicket',
  EXPERIMENTAL: {
    pubsub: true,
  },
  config: {
    Addresses: {
      Swarm: [
        '/dns4/wrtc-star.discovery.libp2p.io/tcp/443/wss/p2p-webrtc-star'
      ],
    },
  },
}

Y.extend(yIpfsConnector, yIndexeddb)
const persistence = new Y.IndexedDB()
const yConfig = (ipfs, id) => ({
  connector: {
    name: 'ipfs',
    room: `thicket:${id}`,
    ipfs,
    syncMethod: 'syncAll',
  },
})

const toBase64 = src =>
  `data:image/gif;base64,${btoa(new Uint8Array(src).reduce((data, byte) => data + String.fromCharCode(byte), ''))}`

// IPFS team has not yet implemented a timeout/cancel feature on fetching files
// if we try to fetch a file that is not in the reach of this node/peer this call will never finish/complete
// read more here
// https://github.com/ipfs/js-ipfs/issues/800#issuecomment-290988388
github sambapos / pmpos3 / src / store / configureProtocol.ts View on Github external
export default (
    terminalId: string,
    networkName: string,
    user: string,
    dispatch: (action: any) => void,
    getState: () => ApplicationState,
    cb: (protocol: any) => void) => {

    yclient(Y);
    yindexeddb(Y);
    const persistence = new Y.IndexedDB();

    let y = new Y(
        networkName, {
            connector: {
                name: 'websockets-client',
                url: 'https://my-websockets-server.herokuapp.com/'
            }
        },
        persistence);

    let chatprotocol = y.define('chat', Y.Array);
    let commitProtocol = y.define('commits', Y.Array);
    let configProtocol = y.define('config', Y.Map);

    dispatchCommitProtocol(dispatch, commitProtocol);
    dispatchConfigProtocol(dispatch, configProtocol);