diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f38305..7eedbdb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+
+### 0.11.2 (2015-01-16)
+
+
+#### Bug Fixes
+
+* **service:** fix possible npe on re-registration of handlers after reconnect ([2225a8ab](http://github.com/knalli/angular-vertxbus/commit/2225a8ab26320942a91902265e7687b189f20e65))
+
+
### 0.11.1 (2015-01-09)
diff --git a/dist/angular-vertxbus.js b/dist/angular-vertxbus.js
index da288ad..7b08393 100644
--- a/dist/angular-vertxbus.js
+++ b/dist/angular-vertxbus.js
@@ -1,4 +1,4 @@
-/*! angular-vertxbus - v0.11.1 - 2015-01-09
+/*! angular-vertxbus - v0.11.2 - 2015-01-16
* http://github.com/knalli/angular-vertxbus
* Copyright (c) 2015 ; Licensed */
(function() {
@@ -436,9 +436,11 @@
for (address in _ref2) {
if (!__hasProp.call(_ref2, address)) continue;
callbacks = _ref2[address];
- for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
- callback = callbacks[_i];
- util.registerHandler(address, callback);
+ if (callbacks != null ? callbacks.length : void 0) {
+ for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
+ callback = callbacks[_i];
+ util.registerHandler(address, callback);
+ }
}
}
$rootScope.$digest();
diff --git a/dist/angular-vertxbus.min.js b/dist/angular-vertxbus.min.js
index fda0a01..fc57262 100644
--- a/dist/angular-vertxbus.min.js
+++ b/dist/angular-vertxbus.min.js
@@ -1 +1 @@
-(function(){var a={}.hasOwnProperty;angular.module("knalli.angular-vertxbus",["ng"]),angular.module("knalli.angular-vertxbus").provider("vertxEventBus",function(){var a,b,c;a={MODULE:"angular-vertxbus",COMPONENT:"wrapper"},b={enabled:!0,debugEnabled:!1,prefix:"vertx-eventbus.",urlServer:""+location.protocol+"//"+location.hostname+":"+(location.port||80),urlPath:"/eventbus",reconnectEnabled:!0,sockjsStateInterval:1e4,sockjsReconnectInterval:1e4,sockjsOptions:{},messageBuffer:0},c=angular.extend({},b),this.enable=function(a){return null==a&&(a=b.enabled),c.enabled=a===!0,this},this.enable.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.enable",this.useDebug=function(a){return null==a&&(a=b.debugEnabled),c.debugEnabled=a===!0,this},this.useDebug.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useDebug",this.usePrefix=function(a){return null==a&&(a=b.prefix),c.prefix=a,this},this.usePrefix.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.usePrefix",this.useUrlServer=function(a){return null==a&&(a=b.urlServer),c.urlServer=a,this},this.useUrlServer.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useUrlServer",this.useUrlPath=function(a){return null==a&&(a=b.urlPath),c.urlPath=a,this},this.useUrlPath.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useUrlPath",this.useReconnect=function(a){return null==a&&(a=b.reconnectEnabled),c.reconnectEnabled=a,this},this.useReconnect.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useReconnect",this.useSockJsStateInterval=function(a){return null==a&&(a=b.sockjsStateInterval),c.sockjsStateInterval=a,this},this.useSockJsStateInterval.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useSockJsStateInterval",this.useSockJsReconnectInterval=function(a){return null==a&&(a=b.sockjsReconnectInterval),c.sockjsReconnectInterval=a,this},this.useSockJsReconnectInterval.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useSockJsReconnectInterval",this.useSockJsOptions=function(a){return null==a&&(a=b.sockjsOptions),c.sockjsOptions=a,this},this.useSockJsOptions.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useSockJsOptions",this.useMessageBuffer=function(a){return null==a&&(a=b.messageBuffer),c.messageBuffer=a,this},this.useMessageBuffer.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useMessageBuffer",this.$get=["$timeout","$log",function(d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;return t=angular.extend({},b,c),j=t.enabled,i=t.debugEnabled,l=t.prefix,s=t.urlServer,r=t.urlPath,m=t.reconnectEnabled,p=t.sockjsStateInterval,o=t.sockjsReconnectInterval,n=t.sockjsOptions,g=null,f="undefined"!=typeof vertx&&null!==vertx?vertx.EventBus:void 0,j&&f?(q=""+s+r,i&&e.debug("[Vert.x EB Stub] Enabled: connecting '"+q+"'"),k=null,h=function(){k=new f(q,void 0,n),k.onopen=function(){i&&e.debug("[Vert.x EB Stub] Connected"),"function"==typeof g.onopen&&g.onopen()},k.onclose=function(){i&&e.debug("[Vert.x EB Stub] Reconnect in "+o+"ms"),"function"==typeof g.onclose&&g.onclose(),m&&d(h,o)}},h(),g={reconnect:function(){return k.close()},close:function(){return k.close()},login:function(a,b,c){return k.login(a,b,c)},send:function(a,b,c){return k.send(a,b,c)},publish:function(a,b){return k.publish(a,b)},registerHandler:function(b,c){var d;return k.registerHandler(b,c),d=function(){g.unregisterHandler(b,c)},d.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.registerHandler (deconstructor)",d},unregisterHandler:function(a,b){return k.unregisterHandler(a,b)},readyState:function(){return k.readyState()},EventBus:f,getOptions:function(){return angular.extend({},c)}},g.reconnect.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.reconnect",g.close.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.close",g.login.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.login",g.send.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.send",g.publish.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.publish",g.registerHandler.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.registerHandler",g.unregisterHandler.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.unregisterHandler",g.readyState.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.readyState",g.getOptions.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.getOptions"):i&&e.debug("[Vert.x EB Stub] Disabled"),g}],this.$get.displayName=""+a.MODULE+"/"+a.COMPONENT+": Factory.get"}),angular.module("knalli.angular-vertxbus").provider("vertxEventBusService",function(){var b,c,d,e,f;b={MODULE:"angular-vertxbus",COMPONENT:"service"},c={loginRequired:!1,loginBlockForSession:!1,skipUnauthorizeds:!0},d=function(){function a(a){this.maxSize=null!=a?a:10,this.items=[]}return a.prototype.push=function(a){return this.items.push(a),this.recalibrateBufferSize()},a.prototype.recalibrateBufferSize=function(){for(;this.items.length>this.maxSize;)this.first();return this},a.prototype.last=function(){return this.items.pop()},a.prototype.first=function(){return this.items.shift(0)},a.prototype.size=function(){return this.items.length},a}(),e=function(){function a(){this.keys=[],this.values=[]}return a.prototype.keys=null,a.prototype.values=null,a.prototype.put=function(a,b){var c;return c=this._indexForKey(a),c>-1?this.values[c]=b:(this.keys.push(a),this.values.push(b)),this},a.prototype.get=function(a){var b;return b=this._indexForKey(a),b>-1?this.values[b]:void 0},a.prototype.containsKey=function(a){var b;return b=this._indexForKey(a),b>-1},a.prototype.containsValue=function(a){var b;return b=this._indexForValue(a),b>-1},a.prototype.remove=function(a){var b;b=this._indexForKey(a),b>-1&&(this.keys[b]=void 0,this.values[b]=void 0)},a.prototype.clear=function(){return this.keys=[],this.values=[],this},a.prototype._indexForKey=function(a){var b,c,d,e,f;for(f=this.keys,b=d=0,e=f.length;e>d;b=++d)if(c=f[b],a===c)return b;return-1},a.prototype._indexForValue=function(a){var b,c,d,e,f;for(f=this.values,b=d=0,e=f.length;e>d;b=++d)if(c=f[b],a===c)return b;return-1},a}(),f=angular.extend({},c),this.requireLogin=function(a){return null==a&&(a=f.loginRequired),f.loginRequired=a,this},this.requireLogin.displayName=""+b.MODULE+"/"+b.COMPONENT+": provider.requireLogin",this.blockForSession=function(a){return null==a&&(a=f.loginBlockForSession),f.loginBlockForSession=a,this},this.blockForSession.displayName=""+b.MODULE+"/"+b.COMPONENT+": provider.blockForSession",this.skipUnauthorizeds=function(a){return null==a&&(a=f.skipUnauthorizeds),f.skipUnauthorizeds=a,this},this.skipUnauthorizeds.displayName=""+b.MODULE+"/"+b.COMPONENT+": provider.skipUnauthorizeds",this.$get=["$rootScope","$q","$interval","$timeout","vertxEventBus","$log",function(c,g,h,i,j,k){var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G;return F=(null!=j?j.getOptions():void 0)||{},p=F.enabled,o=F.debugEnabled,v=F.prefix,B=F.urlServer,A=F.urlPath,w=F.reconnectEnabled,z=F.sockjsStateInterval,y=F.sockjsReconnectInterval,x=F.sockjsOptions,t=F.messageBuffer,n=null!=j&&null!=(G=j.EventBus)?G.CLOSED:void 0,D=!1,s=null,u=new d(t),l=new e,p&&j&&(j.onopen=function(){var b,d,e,f,g,h,i;E.getConnectionState(!0),c.$broadcast(""+v+"system.connected"),i=E.handlers;for(b in i)if(a.call(i,b))for(e=i[b],g=0,h=e.length;h>g;g++)d=e[g],C.registerHandler(b,d);if(c.$digest(),t&&u.size()){for(;u.size();)f=u.first(),"function"==typeof f&&f();c.$digest()}},j.onclose=function(){return E.getConnectionState(!0),c.$broadcast(""+v+"system.disconnected")},j.onclose.displayName=""+b.MODULE+"/"+b.COMPONENT+": 'onclose' handler"),r=function(a){return E.getConnectionState()===j.EventBus.OPEN?(a(),!0):t?(u.push(a),!0):!1},r.displayName=""+b.MODULE+"/"+b.COMPONENT+": ensureOpenConnection",q=function(a){var c;return f.loginRequired?(c=function(){return D?(a(),!0):(o&&k.debug("[Vert.x EB Service] Message was not sent because login is required"),!1)},c.displayName=""+b.MODULE+"/"+b.COMPONENT+": ensureOpenAuthConnection function wrapper",r(c)):r(a)},q.displayName=""+b.MODULE+"/"+b.COMPONENT+": ensureOpenAuthConnection",C={registerHandler:function(a,d){var e;if("function"==typeof d)return o&&k.debug("[Vert.x EB Service] Register handler for "+a),e=function(a,b){d(a,b),c.$digest()},e.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.registerHandler (callback wrapper)",l.put(d,e),j.registerHandler(a,e)},unregisterHandler:function(a,b){"function"==typeof b&&(o&&k.debug("[Vert.x EB Service] Unregister handler for "+a),j.unregisterHandler(a,l.get(b)),l.remove(b))},send:function(a,c,d){var e,f,h;return null==d&&(d=1e4),e=g.defer(),h=function(){return j.send(a,c,function(a){return e?e.resolve(a):void 0}),e?i(function(){return e.reject()},d):void 0},h.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.send (ensureOpenAuthConnection callback)",f=q(h),e&&!f&&e.reject(),null!=e?e.promise:void 0},publish:function(a,c){var d,e;return e=function(){return j.publish(a,c)},e.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.publish (ensureOpenAuthConnection callback)",d=q(e)},login:function(a,d,e){var f,h;return null==e&&(e=5e3),f=g.defer(),h=function(a){return"ok"===(null!=a?a.status:void 0)?(f.resolve(a),c.$broadcast(""+v+"system.login.succeeded",{status:null!=a?a.status:void 0})):(f.reject(a),c.$broadcast(""+v+"system.login.failed",{status:null!=a?a.status:void 0}))},h.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.login (callback)",j.login(a,d,h),i(function(){return f.reject()},e),f.promise}},C.registerHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.registerHandler",C.unregisterHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.unregisterHandler",C.send.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.send",C.publish.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.publish",C.login.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.login",E={handlers:{},registerHandler:function(a,c){var d,e;return E.handlers[a]||(E.handlers[a]=[]),E.handlers[a].push(c),e=null,n===j.EventBus.OPEN&&(e=C.registerHandler(a,c)),d=function(){var b;e&&e(),E.handlers[a]&&(b=E.handlers[a].indexOf(c),b>-1&&E.handlers[a].splice(b,1)),E.handlers[a].length<1&&(E.handlers[a]=void 0)},d.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.registerHandler (deconstructor)",d},unregisterHandler:function(a,b){var c;return E.handlers[a]&&(c=E.handlers[a].indexOf(b),c>-1&&E.handlers[a].splice(c,1)),E.handlers[a].length<1&&(E.handlers[a]=void 0),n===j.EventBus.OPEN?C.unregisterHandler(a,b):void 0},send:function(a,b,c){return null==c&&(c=1e4),C.send(a,b,c)},publish:function(a,b){return C.publish(a,b)},getConnectionState:function(a){return(null!=j?j.EventBus:void 0)?p?a&&(n=j.readyState()):n=j.EventBus.CLOSED:n=3,n},isValidSession:function(){return D},login:function(a,b){return C.login(a,b).then(function(a){return D=!0,a})["catch"](function(a){return D=!1,a})}},E.registerHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.registerHandler",E.unregisterHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.unregisterHandler",E.send.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.send",E.publish.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.publish",E.getConnectionState.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.getConnectionState",E.isValidSession.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.isValidSession",E.login.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.login",m=function(){return E.getConnectionState(!0)},m.displayName=""+b.MODULE+"/"+b.COMPONENT+": periodic connection check",h(m,z),{on:E.registerHandler,addListener:E.registerHandler,un:E.unregisterHandler,removeListener:E.unregisterHandler,send:E.send,publish:E.publish,emit:E.publish,readyState:E.getConnectionState,isEnabled:function(){return p},getBufferCount:function(){return u.size()},isValidSession:function(){return D},login:E.login}}],this.$get.displayName=""+b.MODULE+"/"+b.COMPONENT+": Factory.get"})}).call(this);
\ No newline at end of file
+(function(){var a={}.hasOwnProperty;angular.module("knalli.angular-vertxbus",["ng"]),angular.module("knalli.angular-vertxbus").provider("vertxEventBus",function(){var a,b,c;a={MODULE:"angular-vertxbus",COMPONENT:"wrapper"},b={enabled:!0,debugEnabled:!1,prefix:"vertx-eventbus.",urlServer:""+location.protocol+"//"+location.hostname+":"+(location.port||80),urlPath:"/eventbus",reconnectEnabled:!0,sockjsStateInterval:1e4,sockjsReconnectInterval:1e4,sockjsOptions:{},messageBuffer:0},c=angular.extend({},b),this.enable=function(a){return null==a&&(a=b.enabled),c.enabled=a===!0,this},this.enable.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.enable",this.useDebug=function(a){return null==a&&(a=b.debugEnabled),c.debugEnabled=a===!0,this},this.useDebug.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useDebug",this.usePrefix=function(a){return null==a&&(a=b.prefix),c.prefix=a,this},this.usePrefix.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.usePrefix",this.useUrlServer=function(a){return null==a&&(a=b.urlServer),c.urlServer=a,this},this.useUrlServer.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useUrlServer",this.useUrlPath=function(a){return null==a&&(a=b.urlPath),c.urlPath=a,this},this.useUrlPath.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useUrlPath",this.useReconnect=function(a){return null==a&&(a=b.reconnectEnabled),c.reconnectEnabled=a,this},this.useReconnect.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useReconnect",this.useSockJsStateInterval=function(a){return null==a&&(a=b.sockjsStateInterval),c.sockjsStateInterval=a,this},this.useSockJsStateInterval.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useSockJsStateInterval",this.useSockJsReconnectInterval=function(a){return null==a&&(a=b.sockjsReconnectInterval),c.sockjsReconnectInterval=a,this},this.useSockJsReconnectInterval.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useSockJsReconnectInterval",this.useSockJsOptions=function(a){return null==a&&(a=b.sockjsOptions),c.sockjsOptions=a,this},this.useSockJsOptions.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useSockJsOptions",this.useMessageBuffer=function(a){return null==a&&(a=b.messageBuffer),c.messageBuffer=a,this},this.useMessageBuffer.displayName=""+a.MODULE+"/"+a.COMPONENT+": provider.useMessageBuffer",this.$get=["$timeout","$log",function(d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;return t=angular.extend({},b,c),j=t.enabled,i=t.debugEnabled,l=t.prefix,s=t.urlServer,r=t.urlPath,m=t.reconnectEnabled,p=t.sockjsStateInterval,o=t.sockjsReconnectInterval,n=t.sockjsOptions,g=null,f="undefined"!=typeof vertx&&null!==vertx?vertx.EventBus:void 0,j&&f?(q=""+s+r,i&&e.debug("[Vert.x EB Stub] Enabled: connecting '"+q+"'"),k=null,h=function(){k=new f(q,void 0,n),k.onopen=function(){i&&e.debug("[Vert.x EB Stub] Connected"),"function"==typeof g.onopen&&g.onopen()},k.onclose=function(){i&&e.debug("[Vert.x EB Stub] Reconnect in "+o+"ms"),"function"==typeof g.onclose&&g.onclose(),m&&d(h,o)}},h(),g={reconnect:function(){return k.close()},close:function(){return k.close()},login:function(a,b,c){return k.login(a,b,c)},send:function(a,b,c){return k.send(a,b,c)},publish:function(a,b){return k.publish(a,b)},registerHandler:function(b,c){var d;return k.registerHandler(b,c),d=function(){g.unregisterHandler(b,c)},d.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.registerHandler (deconstructor)",d},unregisterHandler:function(a,b){return k.unregisterHandler(a,b)},readyState:function(){return k.readyState()},EventBus:f,getOptions:function(){return angular.extend({},c)}},g.reconnect.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.reconnect",g.close.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.close",g.login.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.login",g.send.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.send",g.publish.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.publish",g.registerHandler.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.registerHandler",g.unregisterHandler.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.unregisterHandler",g.readyState.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.readyState",g.getOptions.displayName=""+a.MODULE+"/"+a.COMPONENT+": EventBusStub.getOptions"):i&&e.debug("[Vert.x EB Stub] Disabled"),g}],this.$get.displayName=""+a.MODULE+"/"+a.COMPONENT+": Factory.get"}),angular.module("knalli.angular-vertxbus").provider("vertxEventBusService",function(){var b,c,d,e,f;b={MODULE:"angular-vertxbus",COMPONENT:"service"},c={loginRequired:!1,loginBlockForSession:!1,skipUnauthorizeds:!0},d=function(){function a(a){this.maxSize=null!=a?a:10,this.items=[]}return a.prototype.push=function(a){return this.items.push(a),this.recalibrateBufferSize()},a.prototype.recalibrateBufferSize=function(){for(;this.items.length>this.maxSize;)this.first();return this},a.prototype.last=function(){return this.items.pop()},a.prototype.first=function(){return this.items.shift(0)},a.prototype.size=function(){return this.items.length},a}(),e=function(){function a(){this.keys=[],this.values=[]}return a.prototype.keys=null,a.prototype.values=null,a.prototype.put=function(a,b){var c;return c=this._indexForKey(a),c>-1?this.values[c]=b:(this.keys.push(a),this.values.push(b)),this},a.prototype.get=function(a){var b;return b=this._indexForKey(a),b>-1?this.values[b]:void 0},a.prototype.containsKey=function(a){var b;return b=this._indexForKey(a),b>-1},a.prototype.containsValue=function(a){var b;return b=this._indexForValue(a),b>-1},a.prototype.remove=function(a){var b;b=this._indexForKey(a),b>-1&&(this.keys[b]=void 0,this.values[b]=void 0)},a.prototype.clear=function(){return this.keys=[],this.values=[],this},a.prototype._indexForKey=function(a){var b,c,d,e,f;for(f=this.keys,b=d=0,e=f.length;e>d;b=++d)if(c=f[b],a===c)return b;return-1},a.prototype._indexForValue=function(a){var b,c,d,e,f;for(f=this.values,b=d=0,e=f.length;e>d;b=++d)if(c=f[b],a===c)return b;return-1},a}(),f=angular.extend({},c),this.requireLogin=function(a){return null==a&&(a=f.loginRequired),f.loginRequired=a,this},this.requireLogin.displayName=""+b.MODULE+"/"+b.COMPONENT+": provider.requireLogin",this.blockForSession=function(a){return null==a&&(a=f.loginBlockForSession),f.loginBlockForSession=a,this},this.blockForSession.displayName=""+b.MODULE+"/"+b.COMPONENT+": provider.blockForSession",this.skipUnauthorizeds=function(a){return null==a&&(a=f.skipUnauthorizeds),f.skipUnauthorizeds=a,this},this.skipUnauthorizeds.displayName=""+b.MODULE+"/"+b.COMPONENT+": provider.skipUnauthorizeds",this.$get=["$rootScope","$q","$interval","$timeout","vertxEventBus","$log",function(c,g,h,i,j,k){var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G;return F=(null!=j?j.getOptions():void 0)||{},p=F.enabled,o=F.debugEnabled,v=F.prefix,B=F.urlServer,A=F.urlPath,w=F.reconnectEnabled,z=F.sockjsStateInterval,y=F.sockjsReconnectInterval,x=F.sockjsOptions,t=F.messageBuffer,n=null!=j&&null!=(G=j.EventBus)?G.CLOSED:void 0,D=!1,s=null,u=new d(t),l=new e,p&&j&&(j.onopen=function(){var b,d,e,f,g,h,i;E.getConnectionState(!0),c.$broadcast(""+v+"system.connected"),i=E.handlers;for(b in i)if(a.call(i,b)&&(e=i[b],null!=e?e.length:void 0))for(g=0,h=e.length;h>g;g++)d=e[g],C.registerHandler(b,d);if(c.$digest(),t&&u.size()){for(;u.size();)f=u.first(),"function"==typeof f&&f();c.$digest()}},j.onclose=function(){return E.getConnectionState(!0),c.$broadcast(""+v+"system.disconnected")},j.onclose.displayName=""+b.MODULE+"/"+b.COMPONENT+": 'onclose' handler"),r=function(a){return E.getConnectionState()===j.EventBus.OPEN?(a(),!0):t?(u.push(a),!0):!1},r.displayName=""+b.MODULE+"/"+b.COMPONENT+": ensureOpenConnection",q=function(a){var c;return f.loginRequired?(c=function(){return D?(a(),!0):(o&&k.debug("[Vert.x EB Service] Message was not sent because login is required"),!1)},c.displayName=""+b.MODULE+"/"+b.COMPONENT+": ensureOpenAuthConnection function wrapper",r(c)):r(a)},q.displayName=""+b.MODULE+"/"+b.COMPONENT+": ensureOpenAuthConnection",C={registerHandler:function(a,d){var e;if("function"==typeof d)return o&&k.debug("[Vert.x EB Service] Register handler for "+a),e=function(a,b){d(a,b),c.$digest()},e.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.registerHandler (callback wrapper)",l.put(d,e),j.registerHandler(a,e)},unregisterHandler:function(a,b){"function"==typeof b&&(o&&k.debug("[Vert.x EB Service] Unregister handler for "+a),j.unregisterHandler(a,l.get(b)),l.remove(b))},send:function(a,c,d){var e,f,h;return null==d&&(d=1e4),e=g.defer(),h=function(){return j.send(a,c,function(a){return e?e.resolve(a):void 0}),e?i(function(){return e.reject()},d):void 0},h.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.send (ensureOpenAuthConnection callback)",f=q(h),e&&!f&&e.reject(),null!=e?e.promise:void 0},publish:function(a,c){var d,e;return e=function(){return j.publish(a,c)},e.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.publish (ensureOpenAuthConnection callback)",d=q(e)},login:function(a,d,e){var f,h;return null==e&&(e=5e3),f=g.defer(),h=function(a){return"ok"===(null!=a?a.status:void 0)?(f.resolve(a),c.$broadcast(""+v+"system.login.succeeded",{status:null!=a?a.status:void 0})):(f.reject(a),c.$broadcast(""+v+"system.login.failed",{status:null!=a?a.status:void 0}))},h.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.login (callback)",j.login(a,d,h),i(function(){return f.reject()},e),f.promise}},C.registerHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.registerHandler",C.unregisterHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.unregisterHandler",C.send.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.send",C.publish.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.publish",C.login.displayName=""+b.MODULE+"/"+b.COMPONENT+": util.login",E={handlers:{},registerHandler:function(a,c){var d,e;return E.handlers[a]||(E.handlers[a]=[]),E.handlers[a].push(c),e=null,n===j.EventBus.OPEN&&(e=C.registerHandler(a,c)),d=function(){var b;e&&e(),E.handlers[a]&&(b=E.handlers[a].indexOf(c),b>-1&&E.handlers[a].splice(b,1)),E.handlers[a].length<1&&(E.handlers[a]=void 0)},d.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.registerHandler (deconstructor)",d},unregisterHandler:function(a,b){var c;return E.handlers[a]&&(c=E.handlers[a].indexOf(b),c>-1&&E.handlers[a].splice(c,1)),E.handlers[a].length<1&&(E.handlers[a]=void 0),n===j.EventBus.OPEN?C.unregisterHandler(a,b):void 0},send:function(a,b,c){return null==c&&(c=1e4),C.send(a,b,c)},publish:function(a,b){return C.publish(a,b)},getConnectionState:function(a){return(null!=j?j.EventBus:void 0)?p?a&&(n=j.readyState()):n=j.EventBus.CLOSED:n=3,n},isValidSession:function(){return D},login:function(a,b){return C.login(a,b).then(function(a){return D=!0,a})["catch"](function(a){return D=!1,a})}},E.registerHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.registerHandler",E.unregisterHandler.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.unregisterHandler",E.send.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.send",E.publish.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.publish",E.getConnectionState.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.getConnectionState",E.isValidSession.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.isValidSession",E.login.displayName=""+b.MODULE+"/"+b.COMPONENT+": wrapped.login",m=function(){return E.getConnectionState(!0)},m.displayName=""+b.MODULE+"/"+b.COMPONENT+": periodic connection check",h(m,z),{on:E.registerHandler,addListener:E.registerHandler,un:E.unregisterHandler,removeListener:E.unregisterHandler,send:E.send,publish:E.publish,emit:E.publish,readyState:E.getConnectionState,isEnabled:function(){return p},getBufferCount:function(){return u.size()},isValidSession:function(){return D},login:E.login}}],this.$get.displayName=""+b.MODULE+"/"+b.COMPONENT+": Factory.get"})}).call(this);
\ No newline at end of file
diff --git a/dist/requirejs/angular-vertxbus.js b/dist/requirejs/angular-vertxbus.js
index ebe196a..686efa3 100644
--- a/dist/requirejs/angular-vertxbus.js
+++ b/dist/requirejs/angular-vertxbus.js
@@ -1,4 +1,4 @@
-/*! angular-vertxbus - v0.11.1 - 2015-01-09
+/*! angular-vertxbus - v0.11.2 - 2015-01-16
* http://github.com/knalli/angular-vertxbus
* Copyright (c) 2015 ; Licensed */
define(['angular', 'vertxbus'], function(angular) {
@@ -438,9 +438,11 @@ define(['angular', 'vertxbus'], function(angular) {
for (address in _ref2) {
if (!__hasProp.call(_ref2, address)) continue;
callbacks = _ref2[address];
- for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
- callback = callbacks[_i];
- util.registerHandler(address, callback);
+ if (callbacks != null ? callbacks.length : void 0) {
+ for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
+ callback = callbacks[_i];
+ util.registerHandler(address, callback);
+ }
}
}
$rootScope.$digest();