How to use postal - 10 common examples

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 storyteller / Storyteller / client / lib / presentation / editor-presenter.js View on Github external
function applyOutstandingChanges(){
  // If any thing is open, pack it in now
  Postal.publish({
    channel: 'editor',
    topic: 'apply-changes',
    data: {}
  });
}
github apispots / apispots-extension / src / modules / stories / story-maker.js View on Github external
type: 'error',
          timer: 10000
        });
      });

  };


  // event bindings
  postal.subscribe({
    channel: 'stories',
    topic: 'create story',
    callback: _onCreateStory
  });

  postal.subscribe({
    channel: 'stories',
    topic: 'edit story',
    callback: _onEditStory
  });


  return {

    /*
     * Public
     */


  };

}());
github postaljs / postal.federation / lib / node / postal.federation.js View on Github external
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";
    return s.join("");
  };
}

postal.fedx = _.extend({

  clients: {},

  transports: {},

  knownIds: [ postal.instanceId ],

  manifest: {},

  _processingIds: [],

  addToManifest: function(channel, topic, instanceId) {
    instanceId = instanceId || postal.instanceId;
    var manifest = this.manifest[instanceId];
    if(!manifest) {
      manifest = this.manifest[instanceId] = {}
    }
    if(!manifest[channel]) {
      manifest[channel] = [ topic ];
    } else {
      if(!_.contains(manifest[channel], topic)) {
        manifest[channel].push(topic);
github postaljs / postal.federation / lib / node / postal.federation.js View on Github external
/*
 postal.federation
 Author: Jim Cowart (http://freshbrewedcode.com/jimcowart)
 License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license)
 Version 0.1.0
 */
var postal = require( 'postal' );

// BROWSER semi-uuid - it's ghetto and will need to be replaced
// the eventual node version won't need this kind of hackery
if(!postal.utils.getUUID) {
  postal.utils.getUUID = function() {
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
      s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";
    return s.join("");
  };
}

postal.fedx = _.extend({

  clients: {},
github postaljs / postal.federation / lib / node / postal.federation.js View on Github external
/*
 postal.federation
 Author: Jim Cowart (http://freshbrewedcode.com/jimcowart)
 License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license)
 Version 0.1.0
 */
var postal = require( 'postal' );

// BROWSER semi-uuid - it's ghetto and will need to be replaced
// the eventual node version won't need this kind of hackery
if(!postal.utils.getUUID) {
  postal.utils.getUUID = function() {
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
      s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";
    return s.join("");
  };
}

postal.fedx = _.extend({

  clients: {},
github storyteller / Storyteller / client / component-tests / test-queue-count.jsx View on Github external
function publishEngineMessage(topic, data){
	Postal.publish({
		channel: 'engine',
		topic: topic,
		data: data
	});
}
github storyteller / Storyteller / client / component-tests / old / test-spec-explorer.jsx View on Github external
function publishResults(){
	for (var id in AllSpecData.results){
		var completed = AllSpecData.results[id];


		Postal.publish({
			channel: 'engine',
			topic: completed.type,
			data: completed
		});

	}
}
github storyteller / Storyteller / client / lib-tests / test-hierarchy-data-store.js View on Github external
function changeLifecyleFilter(value){
  Postal.publish({
    channel: 'explorer',
    topic: 'lifecycle-filter-changed',
    data: {lifecycle: value}
  });
}
github storyteller / Storyteller / client / component-tests / old / test-expiration-period.jsx View on Github external
beforeEach(() => {
    Postal.reset();
    listener.clear();

    Postal.subscribe({
        channel  : "editor",
        topic    : "*",
        callback : function(data, envelope) {
          data.topic = envelope.topic;
            listener.append(data);
        }
    });

    Postal.subscribe({
        channel  : "engine-request",
        topic    : "*",
        callback : function(data, envelope) {
          data.topic = envelope.topic;
github storyteller / Storyteller / client / component-tests / component-harness.jsx View on Github external
constructor(){
        Postal.reset();
        
        this.store = createStore(Reducer);
        this.store.dispatch(initialization);

		this.div = document.createElement('div');
		document.documentElement.appendChild(this.div);

        this.engineMessages = new Listener('engine-request');
        this.editorMessages = new Listener('editor');
        this.explorerMessages = new Listener('explorer');
        
        var SpecEditorPresenter = require('./../lib/presentation/spec-editor-presenter');

        SpecEditorPresenter(this.store, this.engineRequests);
        
        global.$ = $;

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