https://github.com/canjs/worker-render
Run your single-page application in a web worker
https://github.com/canjs/worker-render
Last synced: about 1 year ago
JSON representation
Run your single-page application in a web worker
- Host: GitHub
- URL: https://github.com/canjs/worker-render
- Owner: canjs
- License: mit
- Created: 2015-06-19T20:49:15.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2020-05-04T22:53:58.000Z (about 6 years ago)
- Last Synced: 2024-04-14T23:20:17.209Z (about 2 years ago)
- Language: JavaScript
- Homepage: http://canjs.github.io/worker-render
- Size: 632 KB
- Stars: 14
- Watchers: 7
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# worker-render
[](http://badge.fury.io/js/worker-render)
Run your applications in a WebWorker and have changes automatically update the DOM.
## Install
```shell
npm install worker-render --save
```
## Usage
To use worker-render you need a module that runs in the window and one that runs in a Web Worker.
Getting your app to run in a Web Worker is up to you, but it is easy with [StealJS](http://stealjs.com/).
### window.js
```js
var windowRender = require("worker-render/window");
var worker = new Worker(...);
windowRender.updateWith(worker);
```
### worker.js
**worker-render** will work with any JavaScript framework. In this example `todoApp` is a
function that returns a DocumentFragment. How you initialize your application is up
to you, but you should do so in the `ready` callback.
```js
var renderer = require("worker-render/worker");
var $ = require("jquery");
var todoApp = require("./todo-app");
renderer.ready(render);
function render(){
$("#app").html(todoApp());
}
```
## License
MIT