sharedb-generic-binding

0.1.0 • Public • Published

sharedb-generic-binding

Base class for binding sharedb's text diff data operations sent to a generic HTML element. Implementation of curran's commit to enable StringBinding, binding.setup() on non-textarea HTML elements.

Usage

npm install sharedb-generic-binding --save

Then use familiar code to bind to a ShareDB connection.

// Require it.
const ShareGenericBinding = require('sharedb-generic-binding');
 
// Setup the connection.
const socket = new WebSocket('ws://YOUR_HOST:YOUR_PORT', [], socketOptions);
const connection = new sharedb.Connection(socket);
const doc = connection.get('examples', 'textarea');
 
// Subscribe to the document.
doc.subscribe((err) => {
  if (err) throw err;
  const element = document.getElementById('YOUR_DIV_OR_WHATEVER');
  const binding = new ShareGenericBinding(element, doc);
  binding.setup();
});

/sharedb-generic-binding/

    Package Sidebar

    Install

    npm i sharedb-generic-binding

    Weekly Downloads

    6

    Version

    0.1.0

    License

    ISC

    Unpacked Size

    10.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • stanographer