mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-04-20 14:51:06 +00:00
Adding built source to repository after last commit
This commit is contained in:
parent
3564224e2b
commit
9e5eb2451e
5 changed files with 29 additions and 1 deletions
Binary file not shown.
|
|
@ -280,6 +280,20 @@ var postal = {
|
|||
return new ChannelDefinition(exch, tpc);
|
||||
},
|
||||
|
||||
subscribe: function(exchange, topic, callback) {
|
||||
var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE,
|
||||
tpc = arguments.length === 3 ? topic : exchange;
|
||||
var channel = this.channel(exch, tpc);
|
||||
return channel.subscribe(callback);
|
||||
},
|
||||
|
||||
publish: function(exchange, topic, payload) {
|
||||
var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE,
|
||||
tpc = arguments.length === 3 ? topic : exchange;
|
||||
var channel = this.channel(exch, tpc);
|
||||
channel.publish(payload);
|
||||
},
|
||||
|
||||
addWireTap: function(callback) {
|
||||
this.configuration.bus.addWireTap(callback);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
2
lib/browser/postal.min.js
vendored
2
lib/browser/postal.min.js
vendored
|
|
@ -1 +1 @@
|
|||
(function(a,b){var c="/",d=50,e=0,f=function(){},g=function(){var a;return function(b){var c=!1;return _.isString(b)?(c=b===a,a=b):(c=_.isEqual(b,a),a=_.clone(b)),!c}},h=function(a,b){this.exchange=a,this.topic=b};h.prototype={subscribe:function(a){var b=new i(this.exchange,this.topic,a);return l.configuration.bus.subscribe(b),b},publish:function(a){l.configuration.bus.publish({exchange:this.exchange,topic:this.topic,data:a,timeStamp:new Date})}};var i=function(a,b,c){this.exchange=a,this.topic=b,this.callback=c,this.priority=d,this.constraints=[],this.maxCalls=e,this.onHandled=f,this.context=null};i.prototype={unsubscribe:function(){l.configuration.bus.unsubscribe(this)},defer:function(){var a=this.callback;return this.callback=function(b){setTimeout(a,0,b)},this},disposeAfter:function(a){if(_.isNaN(a)||a<=0)throw"The value provided to disposeAfter (maxCalls) must be a number greater than zero.";var b=this.onHandled,c=_.after(a,_.bind(function(){this.unsubscribe(this)},this));return this.onHandled=function(){b.apply(this.context,arguments),c()},this},ignoreDuplicates:function(){return this.withConstraint(new g),this},whenHandledThenExecute:function(a){if(!_.isFunction(a))throw"Value provided to 'whenHandledThenExecute' must be a function";return this.onHandled=a,this},withConstraint:function(a){if(!_.isFunction(a))throw"Predicate constraint must be a function";return this.constraints.push(a),this},withConstraints:function(a){var b=this;return _.isArray(a)&&_.each(a,function(a){b.withConstraint(a)}),b},withContext:function(a){return this.context=a,this},withDebounce:function(a){if(_.isNaN(a))throw"Milliseconds must be a number";var b=this.callback;return this.callback=_.debounce(b,a),this},withDelay:function(a){if(_.isNaN(a))throw"Milliseconds must be a number";var b=this.callback;return this.callback=function(c){setTimeout(b,a,c)},this},withPriority:function(a){if(_.isNaN(a))throw"Priority must be a number";return this.priority=a,this},withThrottle:function(a){if(_.isNaN(a))throw"Milliseconds must be a number";var b=this.callback;return this.callback=_.throttle(b,a),this}};var j={cache:{},compare:function(a,b){if(this.cache[b]&&this.cache[b][a])return!0;var c=new RegExp("^"+this.regexify(a)+"$"),d=c.test(b);return d&&(this.cache[b]||(this.cache[b]={}),this.cache[b][a]=!0),d},regexify:function(a){return a.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/#/g,"[A-Z,a-z,0-9]*")}},k={subscriptions:{},wireTaps:[],publish:function(a){_.each(this.wireTaps,function(b){b({exchange:a.exchange,topic:a.topic,data:a.data,timeStamp:a.timeStamp})}),_.each(this.subscriptions[a.exchange],function(b){_.each(b,function(b){l.configuration.resolver.compare(b.topic,a.topic)&&_.all(b.constraints,function(b){return b(a.data)})&&typeof b.callback=="function"&&(b.callback.apply(b.context,[a.data]),b.onHandled())})})},subscribe:function(a){var b,c,d;this.subscriptions[a.exchange]||(this.subscriptions[a.exchange]={}),this.subscriptions[a.exchange][a.topic]||(this.subscriptions[a.exchange][a.topic]=[]),b=this.subscriptions[a.exchange][a.topic].length-1;if(!_.any(this.subscriptions[a.exchange][a.topic],function(b){return b===a})){for(;b>=0;b--)if(this.subscriptions[a.exchange][a.topic][b].priority<=a.priority){this.subscriptions[a.exchange][a.topic].splice(b+1,0,a),c=!0;break}c||this.subscriptions[a.exchange][a.topic].unshift(a)}return _.bind(function(){this.unsubscribe(a)},this)},unsubscribe:function(a){if(this.subscriptions[a.exchange][a.topic]){var b=this.subscriptions[a.exchange][a.topic].length,c=0;for(;c<b;c++)if(this.subscriptions[a.exchange][a.topic][c]===a){this.subscriptions[a.exchange][a.topic].splice(c,1);break}}},addWireTap:function(a){return this.wireTaps.push(a),function(){var b=this.wireTaps.indexOf(a);b!==-1&&this.wireTaps.splice(b,1)}}},l={configuration:{bus:k,resolver:j},channel:function(a,b){var d=arguments.length===2?a:c,e=arguments.length===2?b:a;return new h(d,e)},addWireTap:function(a){this.configuration.bus.addWireTap(a)}};a.postal=l})(window)
|
||||
(function(a,b){var c="/",d=50,e=0,f=function(){},g=function(){var a;return function(b){var c=!1;return _.isString(b)?(c=b===a,a=b):(c=_.isEqual(b,a),a=_.clone(b)),!c}},h=function(a,b){this.exchange=a,this.topic=b};h.prototype={subscribe:function(a){var b=new i(this.exchange,this.topic,a);return l.configuration.bus.subscribe(b),b},publish:function(a){l.configuration.bus.publish({exchange:this.exchange,topic:this.topic,data:a,timeStamp:new Date})}};var i=function(a,b,c){this.exchange=a,this.topic=b,this.callback=c,this.priority=d,this.constraints=[],this.maxCalls=e,this.onHandled=f,this.context=null};i.prototype={unsubscribe:function(){l.configuration.bus.unsubscribe(this)},defer:function(){var a=this.callback;return this.callback=function(b){setTimeout(a,0,b)},this},disposeAfter:function(a){if(_.isNaN(a)||a<=0)throw"The value provided to disposeAfter (maxCalls) must be a number greater than zero.";var b=this.onHandled,c=_.after(a,_.bind(function(){this.unsubscribe(this)},this));return this.onHandled=function(){b.apply(this.context,arguments),c()},this},ignoreDuplicates:function(){return this.withConstraint(new g),this},whenHandledThenExecute:function(a){if(!_.isFunction(a))throw"Value provided to 'whenHandledThenExecute' must be a function";return this.onHandled=a,this},withConstraint:function(a){if(!_.isFunction(a))throw"Predicate constraint must be a function";return this.constraints.push(a),this},withConstraints:function(a){var b=this;return _.isArray(a)&&_.each(a,function(a){b.withConstraint(a)}),b},withContext:function(a){return this.context=a,this},withDebounce:function(a){if(_.isNaN(a))throw"Milliseconds must be a number";var b=this.callback;return this.callback=_.debounce(b,a),this},withDelay:function(a){if(_.isNaN(a))throw"Milliseconds must be a number";var b=this.callback;return this.callback=function(c){setTimeout(b,a,c)},this},withPriority:function(a){if(_.isNaN(a))throw"Priority must be a number";return this.priority=a,this},withThrottle:function(a){if(_.isNaN(a))throw"Milliseconds must be a number";var b=this.callback;return this.callback=_.throttle(b,a),this}};var j={cache:{},compare:function(a,b){if(this.cache[b]&&this.cache[b][a])return!0;var c=new RegExp("^"+this.regexify(a)+"$"),d=c.test(b);return d&&(this.cache[b]||(this.cache[b]={}),this.cache[b][a]=!0),d},regexify:function(a){return a.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/#/g,"[A-Z,a-z,0-9]*")}},k={subscriptions:{},wireTaps:[],publish:function(a){_.each(this.wireTaps,function(b){b({exchange:a.exchange,topic:a.topic,data:a.data,timeStamp:a.timeStamp})}),_.each(this.subscriptions[a.exchange],function(b){_.each(b,function(b){l.configuration.resolver.compare(b.topic,a.topic)&&_.all(b.constraints,function(b){return b(a.data)})&&typeof b.callback=="function"&&(b.callback.apply(b.context,[a.data]),b.onHandled())})})},subscribe:function(a){var b,c,d;this.subscriptions[a.exchange]||(this.subscriptions[a.exchange]={}),this.subscriptions[a.exchange][a.topic]||(this.subscriptions[a.exchange][a.topic]=[]),b=this.subscriptions[a.exchange][a.topic].length-1;if(!_.any(this.subscriptions[a.exchange][a.topic],function(b){return b===a})){for(;b>=0;b--)if(this.subscriptions[a.exchange][a.topic][b].priority<=a.priority){this.subscriptions[a.exchange][a.topic].splice(b+1,0,a),c=!0;break}c||this.subscriptions[a.exchange][a.topic].unshift(a)}return _.bind(function(){this.unsubscribe(a)},this)},unsubscribe:function(a){if(this.subscriptions[a.exchange][a.topic]){var b=this.subscriptions[a.exchange][a.topic].length,c=0;for(;c<b;c++)if(this.subscriptions[a.exchange][a.topic][c]===a){this.subscriptions[a.exchange][a.topic].splice(c,1);break}}},addWireTap:function(a){return this.wireTaps.push(a),function(){var b=this.wireTaps.indexOf(a);b!==-1&&this.wireTaps.splice(b,1)}}},l={configuration:{bus:k,resolver:j},channel:function(a,b){var d=arguments.length===2?a:c,e=arguments.length===2?b:a;return new h(d,e)},subscribe:function(a,b,d){var e=arguments.length===3?a:c,f=arguments.length===3?b:a,g=this.channel(e,f);return g.subscribe(d)},publish:function(a,b,d){var e=arguments.length===3?a:c,f=arguments.length===3?b:a,g=this.channel(e,f);g.publish(d)},addWireTap:function(a){this.configuration.bus.addWireTap(a)}};a.postal=l})(window)
|
||||
|
|
@ -280,6 +280,20 @@ var postal = {
|
|||
return new ChannelDefinition(exch, tpc);
|
||||
},
|
||||
|
||||
subscribe: function(exchange, topic, callback) {
|
||||
var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE,
|
||||
tpc = arguments.length === 3 ? topic : exchange;
|
||||
var channel = this.channel(exch, tpc);
|
||||
return channel.subscribe(callback);
|
||||
},
|
||||
|
||||
publish: function(exchange, topic, payload) {
|
||||
var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE,
|
||||
tpc = arguments.length === 3 ? topic : exchange;
|
||||
var channel = this.channel(exch, tpc);
|
||||
channel.publish(payload);
|
||||
},
|
||||
|
||||
addWireTap: function(callback) {
|
||||
this.configuration.bus.addWireTap(callback);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue