How to use the postal.channel 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 arobson / rabbot / src / queue.js View on Github external
var _ = require( 'lodash' );
var when = require( 'when' );
var pipeline = require( 'when/pipeline' );
var postal = require( 'postal' );
var dispatch = postal.channel( 'rabbit.dispatch' );
var responses = postal.channel( 'rabbit.responses' );
var StatusList = require( './statusList.js' );
var machina = require( 'machina' )( _ );
var Monologue = require( 'monologue.js' )( _ );
var log = require( './log.js' );

var Channel = function( options, connection, topology ) {

	var aliasOptions = function( options, aliases ) {
		var aliased = _.transform( options, function( result, value, key ) {
			var alias = aliases[ key ];
			result[ alias || key ] = value;
		} );
		return _.omit( aliased, Array.prototype.slice.call( arguments, 2 ) );
	};
github arobson / rabbot / src / exchange.js View on Github external
var _ = require( 'lodash' );
var when = require( 'when' );
var pipeline = require( 'when/pipeline' );
var postal = require( 'postal' );
var dispatch = postal.channel( 'rabbit.dispatch' );
var responses = postal.channel( 'rabbit.responses' );
var StatusList = require( './statusList.js' );
var machina = require( 'machina' )( _ );
var Monologue = require( 'monologue.js' )( _ );
var log = require( './log.js' );

var Channel = function( options, connection, topology ) {

	var aliasOptions = function( options, aliases ) {
		var aliased = _.transform( options, function( result, value, key ) {
			var alias = aliases[ key ];
			result[ alias || key ] = value;
		} );
		return _.omit( aliased, Array.prototype.slice.call( arguments, 2 ) );
	};

	var Fsm = machina.Fsm.extend( {
github arobson / rabbot / src / exchange.js View on Github external
var _ = require( 'lodash' );
var when = require( 'when' );
var pipeline = require( 'when/pipeline' );
var postal = require( 'postal' );
var dispatch = postal.channel( 'rabbit.dispatch' );
var responses = postal.channel( 'rabbit.responses' );
var StatusList = require( './statusList.js' );
var machina = require( 'machina' )( _ );
var Monologue = require( 'monologue.js' )( _ );
var log = require( './log.js' );

var Channel = function( options, connection, topology ) {

	var aliasOptions = function( options, aliases ) {
		var aliased = _.transform( options, function( result, value, key ) {
			var alias = aliases[ key ];
			result[ alias || key ] = value;
		} );
		return _.omit( aliased, Array.prototype.slice.call( arguments, 2 ) );
	};
github rjbultitude / theconditionalorchestra / src / scripts / modules / conditions-display.js View on Github external
'use strict';

var postal = require('postal');
var channel = postal.channel();
var frnhtToCelcius = require('../utilities/frnht-to-celcius');

module.exports = function() {
	var tempEl = document.querySelector('[data-ref=temperature]').querySelector('[data-ref=value]');
	var cCoverEl = document.querySelector('[data-ref=cloudCover]').querySelector('[data-ref=value]');
	var aPressureEl = document.querySelector('[data-ref=airPressure]').querySelector('[data-ref=value]');

	function ConditionValues(locationData) {
		this.temperature = frnhtToCelcius(locationData.temperature.value);
		//this.temperature = (locationData.temperature.value - 32) * 5/9;
		this.cloudCover = locationData.cloudCover.value * 100;
		this.airPressure = locationData.pressure.value;
	}

	channel.subscribe('userUpdate', function(locationData) {
		var conditionValues = new ConditionValues(locationData);
github 2600hz / monster-ui / src / js / lib / monster.js View on Github external
retryFunctions: [],
		unlockRetryFunctions: function() {
			_.each(this.retryFunctions, function(fun) {
				fun();
			});

			this.lockRetryAttempt = false;
			this.retryFunctions = [];
		},
		addRetryFunction: function(fun) {
			this.retryFunctions.push(fun);
		}
	};

	var monster = {
		_channel: postal.channel('monster'),

		_fileExists: function(url, success, error) {
			$.ajax({
				url: url,
				type: 'HEAD',
				error: function(status) {
					error && error();
				},
				success: function(status) {
					success && success();
				}
			});
		},

		_requests: {},
github arobson / rabbot / spec / behavior / ackBatch.spec.js View on Github external
require('../setup.js');
var postal = require('postal');
var signal = postal.channel('rabbit.ack');
var AckBatch = require('../../src/ackBatch.js');
var noOp = function () {};

describe('Ack Batching', function () {
  describe('when adding a new message', function () {
    var batch;
    var messageData;
    before(function () {
      batch = new AckBatch('test-queue', 'test-connection', noOp);
      messageData = batch.getMessageOps(101);
      batch.addMessage(messageData);
    });

    function remap (list) {
      return list.map((item) => ({ status: item.status, tag: item.tag }));
    }
github likeastore / notifier / source / execute.js View on Github external
var moment = require('moment');
var postal = require('postal');

var config = require('../config');
var db = require('./db')(config);
var transport = require('./transport');

var logger = require('./utils/logger');

var bus = postal.channel('action:execute');
var subscribers = [];

var handler = function (action, set, message, callback) {
	db.actions.findAndModify({
		query: {_id: action._id},
		update: {$set: set},
		'new': true
	}, function (err, action) {
		logger.info(message + ' ' + action.id);
		callback && callback(err, action);
	});
};

var executor = {
	success: function (action, callback) {
		handler(action, {state: 'executed', executed: moment().utc().toDate()}, 'action executed', callback);
github nicholascloud / presentations / stljs / going-postal / node-demo / pace.js View on Github external
var postal = require('postal');

var pace = 0,
  loop = null,
  paceChannel = postal.channel('fitbuddy', 'pace'),
  paceIncreaseChannel = postal.channel('fitbuddy', 'pace.increase'),
  paceDecreaseChannel = postal.channel('fitbuddy', 'pace.decrease'),
  elevationChangeChannel = postal.channel('fitbuddy', 'elevation.change');

var run = function () {
  paceChannel.publish({currentPace: pace});
};

elevationChangeChannel.subscribe(function (data) {
  var paceChange = -(data.delta / 2);
  module.exports.change(paceChange);
});

module.exports = {
  accel: function (increment, callback) {
    setTimeout(function () {
      if (increment === 0) {
github nicholascloud / presentations / stljs / going-postal / node-demo / elevation.js View on Github external
var postal = require('postal'),
  random = require('./random');

var changeChannel = postal.channel('fitbuddy', 'elevation.change');

var currentElevation = 465; //avg. St. Louis

var changeElevation = function () {
  var delta = random(-5, +5);
  currentElevation += delta;
  changeChannel.publish({
    delta: delta,
    elevation: currentElevation,
    increased: function () {
      return delta > 0;
    },
    decreased: function () {
      return delta < 0;
    },
    toString: function () {
github MiguelBel / MinimalViewer / js / app.js View on Github external
_notify_viewer_loaded(viewer) {
    let channel = postal.channel();

    channel.publish(
      'viewer_loaded',
      {
        element: viewer.identifier
      }
    );

  }
}

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