Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _ = require('underscore');
var postal = require('postal');
var Monologue = require('monologue.js');
var bridge = require('../../lib/monopost.js');
bridge(_, Monologue, postal);
var Worker = function(name) {
this.name = name;
};
Worker.prototype.doWork = function() {
this.emit("work.done", { who: this.name });
};
Monologue.mixin(Worker);
postal.addWireTap(function(d, e){
console.log(e);
});
var instanceA = new Worker("YayWorker");
instanceA.goPostal("OnTheBusNowFolks");
instanceA.doWork();
export default fedx;
function processSignalQ( args ) {
fedx.signalReady.apply( this, args );
}
function processOutboundQ( args ) {
fedx.send.apply( this, args );
}
function processInboundQ( msg ) {
fedx.onFederatedMsg.call( this, msg );
}
postal.addWireTap( function( data, envelope ) {
if ( fedx.canSendRemote( envelope.channel, envelope.topic ) ) {
fedx.sendMessage( envelope );
}
} );
postal.subscribe( {
channel: postal.configuration.SYSTEM_CHANNEL,
topic: "instanceId.changed",
callback: function() {
state._ready = true;
while ( state._signalQueue.length ) {
processSignalQ( state._signalQueue.shift() );
}
while ( state._outboundQueue.length ) {
processOutboundQ( state._outboundQueue.shift() );
}