How to use the postal.configuration 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 / postal.federation / src / index.js View on Github external
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() );
		}
		while ( state._inboundQueue.length ) {
			processInboundQ( state._inboundQueue.shift() );
		}
	}
} );

if ( postal.instanceId() !== undefined ) {
github postaljs / postal.federation / lib / node / postal.federation.js View on Github external
}).withConstraint(function(d, e){
    return d.channel !== "postal.federation" && d.channel !== postal.configuration.SYSTEM_CHANNEL;
  });
github postaljs / postal.federation / lib / node / postal.federation.js View on Github external
topic    : topic,
        callback : function(data, env) {
          env = _.clone(env);
          env.originId = postal.instanceId;
          self.clients[id].send(_.extend({
            envelope: env
          }, self.getFedxWrapper("message")));
        }
      });
    }
  }

}, postal.fedx);

postal.subscribe({
  channel  : postal.configuration.SYSTEM_CHANNEL,
  topic    : "subscription.created",
  callback : function(data, env) {
    postal.fedx.addToManifest(data.channel, data.topic);
    var payload = _.extend({
      envelope: {
        channel  : "postal.federation",
        topic    : "remote.subscription.created",
        originId : postal.instanceId,
        knownIds : postal.fedx.knownIds,
        data     : { channel: data.channel, topic: data.topic }
      }
    }, postal.fedx.getFedxWrapper("subscription.created"));
    postal.fedx.send(payload);
  }
}).withConstraint(function(d, e){
    return d.channel !== "postal.federation" && d.channel !== postal.configuration.SYSTEM_CHANNEL;

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