Giter Site home page Giter Site logo

y-webworker's Introduction

Web Worker Connector for Yjs

It enables communication with a SharedWorker thread. The Shared Worker can handle connections, and save changes using a persistent database (e.g. y-indexeddb), while the clients connect to the shared worker leveraging improved performance. You can also set it up to perform background tasks in the Shared Worker.

In the future you may want set up a Service Worker that keeps the Shared Worker running even after the page is closed - thus enabling synchronization after the page is closed. But this is not yet supported - see issue

  • Only the Shared Worker connects to the server / other clients (less connection overhead)
  • Works best with y-indexeddb
  • Faster start-up when multiple windows are open
  • Background tasks

Use it!

Retrieve this with bower or npm.

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

Example

// Connect to the web worker
Y({
  db: {
    name: 'memory'
  },
  connector: {
    name: 'webworker',
    url: '/bower_components/y-webworker/yjs-webworker.js',
    room: 'my room name'
  },
  sourceDir: '/bower_components', // location of the y-* modules
  share: {
    textarea: 'Text' // y.share.textarea is of type Y.Text
  }
}).then(function (y) {
  // bind the textarea to a shared text element
  y.share.textarea.bind(document.getElementById('textfield'))
}
Modify yjs-webworker.js

The default behavior of yjs-webworker.js is to use y-indexeddb, and connect to the default server using y-websockets-client. For productive systems you should copy & modify the file for your set-up.

License

y-webworker is licensed under the MIT License.

[email protected]

y-webworker's People

Contributors

dmonad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.