How to use the postal.addWireTap function in postal

To help you get started, we’ve selected a few postal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postaljs / monopost.js / examples / node / index.js View on Github external
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();
github postaljs / postal.federation / src / index.js View on Github external
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() );
		}

postal

Pub/Sub library providing wildcard subscriptions, complex message handling, etc. Works server and client-side.

MIT
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis