From 1f8bf876e24e8b78ab3d41f37651e7a9e069e1a0 Mon Sep 17 00:00:00 2001 From: Jim Cowart Date: Thu, 22 Mar 2012 01:34:53 -0400 Subject: [PATCH] README Updates --- README.md | 29 +- ...ard-diags.json => build-browser-diags.json | 2 +- ...rowser-standard.json => build-browser.json | 2 +- lib/browser/standard/postal.diagnostics.js | 33 - .../standard/postal.diagnostics.min.gz.js | Bin 307 -> 0 bytes .../standard/postal.diagnostics.min.js | 1 - lib/browser/standard/postal.js | 414 ------- lib/browser/standard/postal.min.gz.js | Bin 1813 -> 0 bytes lib/browser/standard/postal.min.js | 1 - spec/BindingsResolver.spec.js | 132 +- spec/ChannelDefinition.spec.js | 36 +- spec/DistinctPredicate.spec.js | 138 +-- spec/Postal.spec.js | 1076 ++++++++--------- spec/SubscriptionDefinition.spec.js | 140 +-- spec/runner.html | 40 +- src/main/BindingsResolver.js | 36 +- src/main/ChannelDefinition.js | 48 +- src/main/Constants.js | 8 +- src/main/DistinctPredicate.js | 26 +- src/main/SubscriptionDefinition.js | 16 +- src/main/VersionHeader.js | 10 +- 21 files changed, 854 insertions(+), 1334 deletions(-) rename build-browser-standard-diags.json => build-browser-diags.json (77%) rename build-browser-standard.json => build-browser.json (77%) delete mode 100644 lib/browser/standard/postal.diagnostics.js delete mode 100644 lib/browser/standard/postal.diagnostics.min.gz.js delete mode 100644 lib/browser/standard/postal.diagnostics.min.js delete mode 100644 lib/browser/standard/postal.js delete mode 100644 lib/browser/standard/postal.min.gz.js delete mode 100644 lib/browser/standard/postal.min.js diff --git a/README.md b/README.md index 7ee9f12..a4e828c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,14 @@ JavaScript: // doesn't specify a channel name, so it defaults to "/" (DEFAULT_CHANNEL) var channel = postal.channel( { topic: "Name.Changed" } ); +// this call is identical to the one above +var channel = postal.channel( "Name.Changed" ) + +// To specify a channel name you can do one of the following +var channel = postal.channel( { channel: "MyChannel", topic: "MyTopic" } ); +var channel = postal.channel( "MyChannel","MyTopic" ); + + // subscribe var subscription = channel.subscribe( function( data, envelope ) { $( "#example1" ).html( "Name: " + data.name ); @@ -60,13 +68,18 @@ var starChannel = postal.channel( { channel: "Doctor.Who", topic: "DrWho.*.Chang starSubscription = starChannel.subscribe( function( data ) { $( '
  • ' + data.type + " Changed: " + data.value + '
  • ' ).appendTo( "#example3" ); }); -// demonstrating how we're re-using the channel delcared above to publish, but overriding the topic in the second argument -starChannel.publish( { type: "Name", value:"Rose" }, { topic: "DrWho.NinthDoctor.Companion.Changed" } ); -starChannel.publish( { type: "Name", value:"Martha" }, { topic: "DrWho.TenthDoctor.Companion.Changed" } ); -starChannel.publish( { type: "Name", value:"Amy" }, { topic: "DrWho.Eleventh.Companion.Changed" } ); -starChannel.publish( { type: "Location", value: "The Library" }, { topic: "DrWho.Location.Changed" } ); -starChannel.publish( { type: "DrumBeat", value: "This won't trigger any subscriptions" }, { topic: "TheMaster.DrumBeat.Changed" } ); -starChannel.publish( { type: "Useless", value: "This won't trigger any subscriptions either" }, { topic: "Changed" } ); +/* + demonstrating how we're re-using the channel delcared above to publish, but overriding the topic in the second argument + note to override the topic, you have to use the "envelope" structure, which means an object like: + { channel: "myChannel", topic: "myTopic", data: { someProp: "SomeVal, moarData: "MoarValue" } }; + The only thing to note is that since we are publishing from a channel definition, you don't need to pass "channel" (in fact, it would be ignored) +*/ +starChannel.publish( { topic: "DrWho.NinthDoctor.Companion.Changed", data: { type: "Name", value:"Rose" } } ); +starChannel.publish( { topic: "DrWho.TenthDoctor.Companion.Changed", data: { type: "Name", value:"Martha" } } ); +starChannel.publish( { topic: "DrWho.Eleventh.Companion.Changed", data: { type: "Name", value:"Amy" } } ); +starChannel.publish( { topic: "DrWho.Location.Changed", data: { type: "Location", value: "The Library" } } ); +starChannel.publish( { topic: "TheMaster.DrumBeat.Changed", data: { type: "DrumBeat", value: "This won't trigger any subscriptions" } } ); +starChannel.publish( { topic: "Changed", data: { type: "Useless", value: "This won't trigger any subscriptions either" } } ); starSubscription.unsubscribe(); ``` @@ -79,7 +92,7 @@ var dupChannel = postal.channel( { topic: "WeepingAngel.*" } ), $( '
  • ' + data.value + '
  • ' ).appendTo( "#example4" ); }).ignoreDuplicates(); // demonstrating multiple channels per topic being used -// You can do it this way if you like, but the example above has nicer syntax (and less overhead) +// You can do it this way if you like, but the example above has nicer syntax (and *much* less overhead) postal.channel( { topic: "WeepingAngel.DontBlink" } ) .publish( { value:"Don't Blink" } ); postal.channel( { topic: "WeepingAngel.DontBlink" } ) diff --git a/build-browser-standard-diags.json b/build-browser-diags.json similarity index 77% rename from build-browser-standard-diags.json rename to build-browser-diags.json index bcef85f..9f41844 100644 --- a/build-browser-standard-diags.json +++ b/build-browser-diags.json @@ -1,6 +1,6 @@ { "source": "src/diags", - "output": "lib/browser/standard", + "output": "lib/browser", "lint": {}, "uglify": {}, "gzip": {}, diff --git a/build-browser-standard.json b/build-browser.json similarity index 77% rename from build-browser-standard.json rename to build-browser.json index 63711c5..79d48de 100644 --- a/build-browser-standard.json +++ b/build-browser.json @@ -1,6 +1,6 @@ { "source": "src/main", - "output": "lib/browser/standard", + "output": "lib/browser", "lint": {}, "uglify": {}, "gzip": {}, diff --git a/lib/browser/standard/postal.diagnostics.js b/lib/browser/standard/postal.diagnostics.js deleted file mode 100644 index 5defd32..0000000 --- a/lib/browser/standard/postal.diagnostics.js +++ /dev/null @@ -1,33 +0,0 @@ -(function(root, doc, factory) { - if (typeof define === "function" && define.amd) { - // AMD. Register as an anonymous module. - define(["postal", "underscore"], function(postal, _) { - return factory(postal, _, root, doc); - }); - } else { - // Browser globals - factory(root.postal, root._, root, doc); - } -}(this, document, function(postal, _, global, document, undefined) { - - // this returns a callback that, if invoked, removes the wireTap - return postal.addWireTap(function(data, envelope) { - var all = _.extend(envelope, { data: data }); - if(!JSON) { - throw "This browser or environment does not provide JSON support"; - } - try { - console.log(JSON.stringify(all)); - } - catch(exception) { - try { - all.data = "ERROR: " + exception.message; - console.log(JSON.stringify(all)); - } - catch(ex) { - console.log("Unable to parse data to JSON: " + exception); - } - } - }); - -})); \ No newline at end of file diff --git a/lib/browser/standard/postal.diagnostics.min.gz.js b/lib/browser/standard/postal.diagnostics.min.gz.js deleted file mode 100644 index 8fe66f77e66e09ea7b0c961fe9e2054a6cf139b0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 307 zcmV-30nGj%iwFP&wQ5fQ1C5Z+N&_(v#$P4oP!bGzfR@FR7Y`O{#e;~J93Vu?!rAtC^W)^rV+gfj#dUuxPwPir_DmmgJFAIyjxw?!78s9# zDOPRa3A2b)L}EGykD~60JfuWi= 0; idx--) { - if(subs[idx].priority <= subDef.priority) { - subs.splice(idx + 1, 0, subDef); - found = true; - break; - } - } - if(!found) { - subs.unshift(subDef); - } - return subDef; - }, - - unsubscribe: function(config) { - if(this.subscriptions[config.channel][config.topic]) { - var len = this.subscriptions[config.channel][config.topic].length, - idx = 0; - for ( ; idx < len; idx++ ) { - if (this.subscriptions[config.channel][config.topic][idx] === config) { - this.subscriptions[config.channel][config.topic].splice( idx, 1 ); - break; - } - } - } - }, - - addWireTap: function(callback) { - var self = this; - self.wireTaps.push(callback); - return function() { - var idx = self.wireTaps.indexOf(callback); - if(idx !== -1) { - self.wireTaps.splice(idx,1); - } - }; - } -}; - -var publishPicker = { - "1" : function(envelope) { - if(!envelope) { - throw new Error("publishing from the 'global' postal.publish call requires a valid envelope."); - } - envelope.channel = envelope.channel || DEFAULT_CHANNEL; - envelope.timeStamp = new Date(); - postal.configuration.bus.publish(envelope); - }, - "2" : function(topic, data) { - postal.configuration.bus.publish({ channel: DEFAULT_CHANNEL, topic: topic, timeStamp: new Date(), data: data }); - }, - "3" : function(channel, topic, data) { - postal.configuration.bus.publish({ channel: channel, topic: topic, timeStamp: new Date(), data: data }); - } -}; - -// save some setup time, albeit tiny -localBus.subscriptions[SYSTEM_CHANNEL] = {}; - -var postal = { - configuration: { - bus: localBus, - resolver: bindingsResolver - }, - - channel: function() { - var len = arguments.length, - channel = arguments[0], - tpc = arguments[1]; - if(len === 1) { - if(Object.prototype.toString.call(channel) === "[object String]") { - channel = DEFAULT_CHANNEL; - tpc = arguments[0]; - } - else { - channel = arguments[0].channel || DEFAULT_CHANNEL; - tpc = arguments[0].topic; - } - } - return new ChannelDefinition(channel, tpc); - }, - - subscribe: function(options) { - var callback = options.callback, - topic = options.topic, - channel = options.channel || DEFAULT_CHANNEL; - return new SubscriptionDefinition(channel, topic, callback); - }, - - publish: function() { - var len = arguments.length; - if(publishPicker[len]) { - publishPicker[len].apply(this, arguments); - } - }, - - addWireTap: function(callback) { - return this.configuration.bus.addWireTap(callback); - }, - - linkChannels: function(sources, destinations) { - var result = []; - if(!_.isArray(sources)) { - sources = [sources]; - } - if(!_.isArray(destinations)) { - destinations = [destinations]; - } - _.each(sources, function(source){ - var sourceTopic = source.topic || "*"; - _.each(destinations, function(destination) { - var destChannel = destination.channel || DEFAULT_CHANNEL; - result.push( - postal.subscribe({ - channel: source.channel || DEFAULT_CHANNEL, - topic: source.topic || "*", - callback : function(data, env) { - var newEnv = env; - newEnv.topic = _.isFunction(destination.topic) ? destination.topic(env.topic) : destination.topic || env.topic; - newEnv.channel = destChannel; - newEnv.data = data; - postal.publish(newEnv); - } - }) - ); - }); - }); - return result; - } -}; - - - global.postal = postal; - return postal; -})); \ No newline at end of file diff --git a/lib/browser/standard/postal.min.gz.js b/lib/browser/standard/postal.min.gz.js deleted file mode 100644 index f93772fa7f0f78485058b5d8b50717192436a350..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1813 zcmV+w2kQ7AiwFP&wQ5fQ1HD*nZ`(Ey{ws<$IAX)7c87hKRW2yn4EwUSSc46i>lGwL z*=l4-rKG&n)_>noq$tX9UWx(zVvBFb?ieIZ&g-7xVGm)?A zb(AIn1qElwsGo~#FALl~-R-blznCsjzxc%ii`@lIW41&sE*qAm)q2p98l1`2ET4}R zQ7X(`bz)l6Ic*~vcJ0Z8hN^2a2>@8kENu2`w{s-|{$ZVN#D|)0N}{xXLu-M{kQaH9 zt{O>|S|Mwy(C8X~nHfD?t^2zNFdX&H)c0J8z1#x@wQZzMnvpw>GP-Szy}4=K;55q^ z<(Gu(b}7?Bru8jJ%y^MkwWKMa+@0u^l=L>3B0ajHH?KiJMOM09~ee>ziIq`vgQ<42&t{T{jgCOb!Pu&^013*{-1{nI5&E5{a5A=6tf-VKaRI|L zWN97;4h-GoJ6EcYh0q9*!3CW4Jfvlr-3G2t4D^L?99WFfRSt3LO;ctm2h}V0Hr#!# z(|Y~dI%lBl;WIKauGga10`SYvZv<~@v5)wXg8a9k&mjKS9kh=R%R6@9wgLDaELgAE zNb4tR^j?a%1H&8G=+V6$;sQ78sP>=^)kulKHrxQLNsl2F5Cr8Q3%hj9_b&qo8DVaB zQn!7G-$x8d9qrx-R={*|zmFJX{zx<64*@db>W=Y`Ed62cg*a!n)Om!fN=9$Ln;tGm z4vTFHNIJ^f_~!zccaKCmI-AuwMJ0QWe> zkb{ks+U>?|vTYIGSDPF`qN0-E+-9*|Xsi?#*Qpd2wA2}uO>6EXk${hJdPBQ<)rbIS zz`8`Ss~WI7eYESs=8aAj!mWHh>fBEkq^OGQO32XMVZe3VRyn8o@5l+RANn2Y!-vvJ zqb=wPH?1ovKG@KxnhJ&i6T-NSUyJ_GOCY;}>jMOWRWfndZo7Zc#I!#pcz_i5&b4@xp>!bSj#n01bo3nv# zQ++!Al12RF1U-4b1wcj!HObQB8yZwNo*@GUI4X_fzqN-QDC69)%&aHs=nkOmrL9on z409l#6F2XGx>3ZB2sxciCeEm%ic+E=+u1(mM^tltSCpPh2@v^)E1)*_5?O43i-mW* z$_hraV^6;V^clXVyvUQ{O9OjW5E~$;O=C~wS0XD)0c;u3p-vmhO95>1jU}ZDlrQ!e z{zQmAG#SoVc$EkyC+#sRZxXXTj^C6a*XAk1`!QLX3cU{-Wq+d3t2&p9PGF zk>KeP&4cmA?p2Sc8d^tKSNsa;2RT)lO&|U_F>cn?HNzIs=w&6wyerP`#Jqc-cM1rq zlZpCu3L2-7xz~aBGTuF785VWco2B{XYpt`Jon!kvwpbp@&Vkz*S*U0<^m5h932>8* z%TDfY68?mk7`of}&;00MIM(yHi)E~tr*s|-thF=uUX9^9d*J@2+~e5?#W)h?k!Dm6 znShVZ%tsKLjydl|n;tAImn875ybBWB(mJI8N7GSSWk&<0YR)1hE?e{;$+l|obQJ&q D(TIi6 diff --git a/lib/browser/standard/postal.min.js b/lib/browser/standard/postal.min.js deleted file mode 100644 index 4ad9154..0000000 --- a/lib/browser/standard/postal.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a,b,c){typeof define=="function"&&define.amd?define(["underscore"],function(d){return c(d,a,b)}):c(a._,a,b)})(this,document,function(a,b,c,d){var e="/",f=50,g=0,h="postal",i=function(){},j=function(){var b;return function(c){var d=!1;return a.isString(c)?(d=c===b,b=c):(d=a.isEqual(c,b),b=a.clone(c)),!d}},k=function(a,b){this.channel=a||e,this._topic=b||""};k.prototype={subscribe:function(){var a=arguments.length;if(a===1)return new l(this.channel,this._topic,arguments[0]);if(a===2)return new l(this.channel,arguments[0],arguments[1])},publish:function(a){var b={channel:this.channel,topic:this._topic,data:a};a.topic&&a.data&&(b=a,b.channel=b.channel||this.channel),b.timeStamp=new Date,p.configuration.bus.publish(b)},topic:function(a){return a===this._topic?this:new k(this.channel,a)}};var l=function(a,b,c){this.channel=a,this.topic=b,this.callback=c,this.priority=f,this.constraints=new Array(0),this.maxCalls=g,this.onHandled=i,this.context=null,p.configuration.bus.publish({channel:h,topic:"subscription.created",timeStamp:new Date,data:{event:"subscription.created",channel:a,topic:b}}),p.configuration.bus.subscribe(this)};l.prototype={unsubscribe:function(){p.configuration.bus.unsubscribe(this),p.configuration.bus.publish({channel:h,topic:"subscription.removed",timeStamp:new Date,data:{event:"subscription.removed",channel:this.channel,topic:this.topic}})},defer:function(){var a=this.callback;return this.callback=function(b){setTimeout(a,0,b)},this},disposeAfter:function(b){if(a.isNaN(b)||b<=0)throw"The value provided to disposeAfter (maxCalls) must be a number greater than zero.";var c=this.onHandled,d=a.after(b,a.bind(function(){this.unsubscribe(this)},this));return this.onHandled=function(){c.apply(this.context,arguments),d()},this},ignoreDuplicates:function(){return this.withConstraint(new j),this},whenHandledThenExecute:function(b){if(!a.isFunction(b))throw"Value provided to 'whenHandledThenExecute' must be a function";return this.onHandled=b,this},withConstraint:function(b){if(!a.isFunction(b))throw"Predicate constraint must be a function";return this.constraints.push(b),this},withConstraints:function(b){var c=this;return a.isArray(b)&&a.each(b,function(a){c.withConstraint(a)}),c},withContext:function(a){return this.context=a,this},withDebounce:function(b){if(a.isNaN(b))throw"Milliseconds must be a number";var c=this.callback;return this.callback=a.debounce(c,b),this},withDelay:function(b){if(a.isNaN(b))throw"Milliseconds must be a number";var c=this.callback;return this.callback=function(a){setTimeout(c,b,a)},this},withPriority:function(b){if(a.isNaN(b))throw"Priority must be a number";return this.priority=b,this},withThrottle:function(b){if(a.isNaN(b))throw"Milliseconds must be a number";var c=this.callback;return this.callback=a.throttle(c,b),this},subscribe:function(a){return this.callback=callback,this}};var m={cache:{},compare:function(a,b){if(this.cache[b]&&this.cache[b][a])return!0;var c=new RegExp("^"+a.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/#/g,"[A-Z,a-z,0-9]*")+"$"),d=c.test(b);return d&&(this.cache[b]||(this.cache[b]={}),this.cache[b][a]=!0),d}},n={subscriptions:{},wireTaps:new Array(0),publish:function(b){a.each(this.wireTaps,function(a){a(b.data,b)}),a.each(this.subscriptions[b.channel],function(c){a.each(c,function(c){p.configuration.resolver.compare(c.topic,b.topic)&&a.all(c.constraints,function(a){return a(b.data)})&&typeof c.callback=="function"&&(c.callback.apply(c.context,[b.data,b]),c.onHandled())})})},subscribe:function(a){var b,c,d,e=this.subscriptions[a.channel],f;e||(e=this.subscriptions[a.channel]={}),f=this.subscriptions[a.channel][a.topic],f||(f=this.subscriptions[a.channel][a.topic]=new Array(0)),b=f.length-1;for(;b>=0;b--)if(f[b].priority<=a.priority){f.splice(b+1,0,a),c=!0;break}return c||f.unshift(a),a},unsubscribe:function(a){if(this.subscriptions[a.channel][a.topic]){var b=this.subscriptions[a.channel][a.topic].length,c=0;for(;c - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + -

    +

    diff --git a/src/main/BindingsResolver.js b/src/main/BindingsResolver.js index da1d5a3..7557302 100644 --- a/src/main/BindingsResolver.js +++ b/src/main/BindingsResolver.js @@ -1,21 +1,21 @@ var bindingsResolver = { - cache: { }, + cache: { }, - compare: function(binding, topic) { - if(this.cache[topic] && this.cache[topic][binding]) { - return true; - } - // binding.replace(/\./g,"\\.") // escape actual periods - // .replace(/\*/g, ".*") // asterisks match any value - // .replace(/#/g, "[A-Z,a-z,0-9]*"); // hash matches any alpha-numeric 'word' - var rgx = new RegExp("^" + binding.replace(/\./g,"\\.").replace(/\*/g, ".*").replace(/#/g, "[A-Z,a-z,0-9]*") + "$"), - result = rgx.test(topic); - if(result) { - if(!this.cache[topic]) { - this.cache[topic] = {}; - } - this.cache[topic][binding] = true; - } - return result; - } + compare: function(binding, topic) { + if(this.cache[topic] && this.cache[topic][binding]) { + return true; + } + // binding.replace(/\./g,"\\.") // escape actual periods + // .replace(/\*/g, ".*") // asterisks match any value + // .replace(/#/g, "[A-Z,a-z,0-9]*"); // hash matches any alpha-numeric 'word' + var rgx = new RegExp("^" + binding.replace(/\./g,"\\.").replace(/\*/g, ".*").replace(/#/g, "[A-Z,a-z,0-9]*") + "$"), + result = rgx.test(topic); + if(result) { + if(!this.cache[topic]) { + this.cache[topic] = {}; + } + this.cache[topic][binding] = true; + } + return result; + } }; diff --git a/src/main/ChannelDefinition.js b/src/main/ChannelDefinition.js index 8db0848..c5ae132 100644 --- a/src/main/ChannelDefinition.js +++ b/src/main/ChannelDefinition.js @@ -1,33 +1,33 @@ var ChannelDefinition = function(channelName, defaultTopic) { - this.channel = channelName || DEFAULT_CHANNEL; - this._topic = defaultTopic || ""; + this.channel = channelName || DEFAULT_CHANNEL; + this._topic = defaultTopic || ""; }; ChannelDefinition.prototype = { - subscribe: function() { - var len = arguments.length; - if(len === 1) { - return new SubscriptionDefinition(this.channel, this._topic, arguments[0]); - } - else if (len === 2) { - return new SubscriptionDefinition(this.channel, arguments[0], arguments[1]); - } - }, + subscribe: function() { + var len = arguments.length; + if(len === 1) { + return new SubscriptionDefinition(this.channel, this._topic, arguments[0]); + } + else if (len === 2) { + return new SubscriptionDefinition(this.channel, arguments[0], arguments[1]); + } + }, - publish: function(obj) { - var envelope = { - channel: this.channel, - topic: this._topic, - data: obj - }; - // If this is an envelope.... - if( obj.topic && obj.data ) { - envelope = obj; - envelope.channel = envelope.channel || this.channel; - } - envelope.timeStamp = new Date(); + publish: function(obj) { + var envelope = { + channel: this.channel, + topic: this._topic, + data: obj + }; + // If this is an envelope.... + if( obj.topic && obj.data ) { + envelope = obj; + envelope.channel = envelope.channel || this.channel; + } + envelope.timeStamp = new Date(); postal.configuration.bus.publish(envelope); - }, + }, topic: function(topic) { if(topic === this._topic) { diff --git a/src/main/Constants.js b/src/main/Constants.js index ac13e2a..411258a 100644 --- a/src/main/Constants.js +++ b/src/main/Constants.js @@ -1,5 +1,5 @@ var DEFAULT_CHANNEL = "/", - DEFAULT_PRIORITY = 50, - DEFAULT_DISPOSEAFTER = 0, - SYSTEM_CHANNEL = "postal", - NO_OP = function() { }; + DEFAULT_PRIORITY = 50, + DEFAULT_DISPOSEAFTER = 0, + SYSTEM_CHANNEL = "postal", + NO_OP = function() { }; diff --git a/src/main/DistinctPredicate.js b/src/main/DistinctPredicate.js index a6abd18..6e443be 100644 --- a/src/main/DistinctPredicate.js +++ b/src/main/DistinctPredicate.js @@ -1,15 +1,15 @@ var DistinctPredicate = function() { - var previous; - return function(data) { - var eq = false; - if(_.isString(data)) { - eq = data === previous; - previous = data; - } - else { - eq = _.isEqual(data, previous); - previous = _.clone(data); - } - return !eq; - }; + var previous; + return function(data) { + var eq = false; + if(_.isString(data)) { + eq = data === previous; + previous = data; + } + else { + eq = _.isEqual(data, previous); + previous = _.clone(data); + } + return !eq; + }; }; diff --git a/src/main/SubscriptionDefinition.js b/src/main/SubscriptionDefinition.js index 55a86ec..31fa801 100644 --- a/src/main/SubscriptionDefinition.js +++ b/src/main/SubscriptionDefinition.js @@ -8,14 +8,14 @@ var SubscriptionDefinition = function(channel, topic, callback) { this.onHandled = NO_OP; this.context = null; postal.configuration.bus.publish({ - channel: SYSTEM_CHANNEL, - topic: "subscription.created", - timeStamp: new Date(), - data: { - event: "subscription.created", - channel: channel, - topic: topic - } + channel: SYSTEM_CHANNEL, + topic: "subscription.created", + timeStamp: new Date(), + data: { + event: "subscription.created", + channel: channel, + topic: topic + } }); postal.configuration.bus.subscribe(this); diff --git a/src/main/VersionHeader.js b/src/main/VersionHeader.js index 388e7f2..d61c1cd 100644 --- a/src/main/VersionHeader.js +++ b/src/main/VersionHeader.js @@ -1,6 +1,6 @@ /* - postal.js - Author: Jim Cowart - License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) - Version 0.6.0 -*/ + postal.js + Author: Jim Cowart + License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) + Version 0.6.0 + */