Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Message.js Build Status

npm

MessagePassing implementation.

Document

How to use

Browser

<script src="lib/Task.js">
<script src="lib/Message.js">
<script>

    function Foo() {
        this.inbox = function(task, name, data) {
            task.set(name, data.msg + "Foo").pass();
        };
    }
    function Bar() {
        this.inbox = function(task, name, data) {
            task.set(name, data.msg + "Bar").pass();
        };
    }

    var foo1 = new Foo();
    var foo2 = new Foo();
    var bar = new Bar();
    var msg = new Message({ a: foo1, b: foo2, c: bar });

    msg.post({ msg: "Hello" }, function(err, buffer) {
        console.log( JSON.stringify( Task.objectize(buffer) ) ); // {"a":"HelloFoo","b":"HelloFoo","c":"HelloBar"}
    });

</script>

WebWorkers

importScripts("lib/Task.js");
importScripts("lib/Message.js");

...

Node.js

var Task = require("lib/Task.js");
var Message = require("lib/Message.js");

...

About

MessagePassing implementation

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages