How to use the postal.subscribe 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 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 flyingeinstein / tread-station / ui / client / js / treadmill.js View on Github external
let deferred = Q.defer();
                deferred.cookie = this.cookie;
                this.pending.push(deferred);
                //console.log("defer "+deferred.cookie+": ", deferred);
                return deferred;
            },
            promise: function(cookie) {
                for(let i=0,_i=this.pending.length; i<_i; i++)
                    if(this.pending[i] && this.pending[i].cookie === cookie ) {
                        let defer = this.pending[i];
                        this.pending[i] = null;
                        return defer;
                    }
                    return null;
            },
            response_handler: postal.subscribe({
                channel: "system",
                topic: "rpc.response",
                callback: function (data, envelope) {
                    //console.log("rpc-response: ", envelope);
                    let defer = this._rpc.promise(data.cookie);
                    if(defer!==null) {
                        defer.resolve(data.response);
                    }
                }.bind(this)
            })
        }
    };

    if(arguments.length <2)
        return false;
    let args = [];
github fonoster / routr / mod / core / context_storage.js View on Github external
constructor(sipProvider) {
        this.storage = new ArrayList()
        this.sipProvider = sipProvider

        postal.subscribe({
            channel: "processor",
            topic: "transaction.terminated",
            callback: data => this.removeContext(data.transactionId)
        })

        postal.subscribe({
            channel: "processor",
            topic: "transaction.cancel",
            callback: data => this.cancelTransaction(data.transactionId)
        })
    }
github storyteller / Storyteller / client / components / editing / tables / table-editor.jsx View on Github external
componentDidMount(){
		this.subscription = Postal.subscribe({
			channel: 'editor',
			topic: 'add-table-step',
			callback: data => {
				if (this.props.adder.active){
					if (data.evt) data.evt.preventDefault();
					this.props.addOnClick(data.evt);

				}
			}
		});
	},
github storyteller / Storyteller / client / lib / presentation / editor-presenter.js View on Github external
subscribe(topic, callback){
    this.subscriptions.push(Postal.subscribe({
      channel: 'editor',
      topic: topic,
      callback: callback
    }));
  }
github apiumhub / cmvp-seed / app / services / EventBus.js View on Github external
EventBus.prototype.subscribe = function (parameters) {
        return {
            unsubscribe: postal.subscribe(parameters).unsubscribe,
            channel: parameters.channel,
            topic: parameters.topic
        };
    };
github Hitachi-Automotive-And-Industry-Lab / semantic-segmentation-editor / imports / common / SseMsg.js View on Github external
static register(obj) {
        obj.actions = {};
        obj.subscription = postal.subscribe({
            channel: "ui",
            topic: "msg",
            callback: (function (data) {
                if (this.actions[data.name]) {
                    SseMsg.saveLastMsg(data.name, data.argument);
                    this.actions[data.name](data.argument);
                }
            }).bind(obj)
        });

        obj.sendMsg = (function (name, argument) {
            postal.publish({
                channel: "ui",
                topic: "msg",
                data: {
                    name: name,
github fonoster / routr / mod / location / locator.js View on Github external
callback: (data, envelope) => {
                const aor = aorAsString(data.addressOfRecord)
                this.removeEndpoint(aor, data.contactURI, data.isWildcard)
            }
        })

        postal.subscribe({
            channel: "locator",
            topic: "endpoint.add",
            callback: (data, envelope) => {
                const aor = aorAsString(data.addressOfRecord)
                this.addEndpoint(aor, data.route)
            }
        })

        postal.subscribe({
            channel: "locator",
            topic: "endpoint.find",
            callback: (data, envelope) => {
                const response = this.findEndpoint(
                  aorAsString(data.addressOfRecord))
                postal.publish({
                    channel: "locator",
                    topic: "endpoint.find.reply",
                    data: {
                        response: response,
                        requestId: data.requestId
                    }
                })
            }
        })
    }
github storyteller / Storyteller / client / components / header / help.jsx View on Github external
componentDidMount(){
    Postal.subscribe({
      channel: 'explorer',
      topic: 'shortcut-help',
      callback: data => {
        if (!this.state.isModalOpen){
          this.handleToggle();
        }
      }
    })
  },
github storyteller / Storyteller / client / components / editing / editors / textbox-editor.jsx View on Github external
componentDidMount: function(){
		var element = ReactDOM.findDOMNode(this);
		element.focus();

		if (this.state.value){
            if (this.props.arg.changed){
                element.setSelectionRange(this.state.value.length, this.state.value.length);
            }
            else {
                element.setSelectionRange(0, this.state.value.length);
            }
			
		}

		this.subscription = Postal.subscribe({
			channel: 'editor',
			topic: 'apply-changes',
			callback: (data, envelope) => {
				var value = ReactDOM.findDOMNode(this).value;
				if (value != this.state.value){
					this.publishChange(value);
				}
			}
		});
	},

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