0.1.0 • Published 6 years ago

sharedb-generic-binding v0.1.0

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

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