3.0.2 • Published 8 years ago

jobworker v3.0.2

Weekly downloads
16
License
-
Repository
github
Last release
8 years ago

JobWorker

NPM version Build Status

JobWorker is an utility to create background job workers. This module provides a transport to work with WebWorker, but can also be transport agnostic.

Installation

$ npm install jobworker

Usage

Create a web-worker "myworker.js" using:

var jw = require("jobworker");

var server = new jw.WebWorkerServer();

// Register some methods
server.register({
    // Task can be sync
    hello: function() {
        return "World";
    },

    // Or async:
    testAsync: function() {
        return doSomethingSync()
        .then(function() {
            // it should return a promise
        });
    }
});

// Run the worker
server.start();

And in your application, access the web-worker using:

var jw = require("jobworker");

var worker = new jw.WebWorkerClient("myworker.js");


// Call a method
worker.callMethod("hello")
.then(function(msg) {

});

// Or create a binded nethod:
var testAsync = worker.method("testAsync");

Custom Transport

Events and WebWorker are good examples on how to write a custom transport.

3.0.2

8 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.0.0

9 years ago

1.0.0

9 years ago