JSPM

  • Created
  • Published
  • Downloads 81295
  • Score
    100M100P100Q157590F
  • License MIT

WebRTC Connector for Yjs

Package Exports

  • y-webrtc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (y-webrtc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

WebRTC Connector for Yjs

It propagates document updates directly to all users via WebRTC. While WebRTC is not the most reliable connector, messages are propagated with almost no delay.

  • Very fast message propagation (not noticeable)
  • Very easy to use
  • Very little server load (you still have to set up a signaling server)
  • Not suited for a large amount of collaborators
  • WebRTC is not supported in all browsers, and some have troubles communicating with each other

We provide you with a free signaling server (it is used by default), but in production you should set up your own signaling server. You could use the signalmaster from &yet, which is very easy to set up.

Use it!

Retrieve this with bower or npm, and use it as a js library or as a custom polymer element.

NPM
npm install y-webrtc --save
Bower
bower install y-webrtc --save

Start Hacking

This connector is also a nice starting point to build your own connector. The only 75 SLOCs of code are pretty well documented and understandable. If you have any troubles, don't hesitate to ask me for help!

Example

Y({
  db: {
    name: 'memory'
  },
  connector: {
    name: 'webrtc', // choose the webrtc connector
    room: 'Textarea-example-dev'
  },
  sourceDir: '/bower_components', // location of the y-* modules
  share: {
    textarea: 'Text' // y.share.textarea is of type Y.Text
  }
  // types: ['Richtext', 'Array'] // optional list of types you want to import
}).then(function (y) {
  // bind the textarea to a shared text element
  y.share.textarea.bind(document.getElementById('textfield'))
}

License

Yjs is licensed under the MIT License.

kevin.jahns@rwth-aachen.de