Git Product home page Git Product logo

y-indexeddb's Introduction

y-indexeddb

IndexedDB database provider for Yjs. Documentation

Use the IndexedDB database adapter to store your shared data persistently in the browser. The next time you join the session, your changes will still be there.

  • Minimizes the amount of data exchanged between server and client
  • Makes offline editing possible

Getting Started

You find the complete documentation published online: API documentation.

npm i --save y-indexeddb
const provider = new IndexeddbPersistence(docName, ydoc)

provider.on('synced', () => {
  console.log('content from the database is loaded')
})

API

provider = new IndexeddbPersistence(docName: string, ydoc: Y.Doc)
Create a y-indexeddb persistence provider. Specify docName as a unique string that identifies this document. In most cases, you want to use the same identifier that is used as the room-name in the connection provider.
provider.on('synced', function(idbPersistence: IndexeddbPersistence))
The "synced" event is fired when the connection to the database has been established and all available content has been loaded. The event is also fired when no content is available yet.
provider.set(key: any, value: any): Promise<any>
Set a custom property on the provider instance. You can use this to store relevant meta-information for the persisted document. However, the content will not be synced with other peers.
provider.get(key: any): Promise>any<
Retrieve a stored value.
provider.del(key: any): Promise>undefined<
Delete a stored value.
provider.destroy(): Promise
Close the connection to the database and stop syncing the document. This method is automatically called when the Yjs document is destroyed (e.g. ydoc.destroy()).
provider.clearData(): Promise
Destroy this database and remove the stored document and all related meta-information from the database.

License

Yjs is licensed under the MIT License.

[email protected]

y-indexeddb's People

Contributors

dmonad avatar ajhyndman avatar brechtcs avatar handtrix avatar fantactuka avatar willheslam avatar

Stargazers

Andrew Heller avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.