catiline icon indicating copy to clipboard operation
catiline copied to clipboard

MessageChannel

Open calvinmetcalf opened this issue 10 years ago • 1 comments

var p2;
var port = cw(function(data,cb){
    this.x = new MessageChannel();
    this.on('mess',function(a){
        this.x.port1.postMessage(a);
    });
    cb(this.x.port2,[this.x.port2]);
});

port.data(1).then(function(a){
    console.log('yes');
    p2=a;
},function(a){
    console.log(a);
});

p2.onmessage=function(a){
    console.log('msg ',a.data);
}

port.fire('mess','hello there')

this could be a polyfill for sub workers in chrome

calvinmetcalf avatar Jul 18 '13 13:07 calvinmetcalf