0.0.6 • Published 11 years ago

uupaa.message.js v0.0.6

Weekly downloads
9
License
MIT
Repository
github
Last release
11 years ago

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");

...
0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago