diff --git a/dist/ngAutobahn.js b/dist/ngAutobahn.js index 56f1472..d00f0e1 100644 --- a/dist/ngAutobahn.js +++ b/dist/ngAutobahn.js @@ -1,5 +1,5 @@ /** - * ngAutobahn - v0.0.6 - 2015-12-08 + * ngAutobahn - v0.0.7 - 2015-12-08 * https://github.com/ef-ctx/ngAutobahn * * Copyright (c) 2015 EF CTX @@ -490,12 +490,15 @@ ***************************************************************/ function unsubscribeBroker(brokerFacade) { + var broker; + if (!brokerFacade) { throw new Error('ngAutobahnSession.unsubscribeBroker error. No broker provided'); } else { - var broker = _getBrokerByBrokerFacade(brokerFacade); - _unsubscribeBroker(broker); - delete _brokers[broker.subscription.id]; + broker = _getBrokerByBrokerFacade(brokerFacade); + + return _unsubscribeBroker(broker) + .then(_deleteBroker); } } @@ -588,8 +591,22 @@ * HELPERS ***************************************************************/ + function _deleteBroker(broker) { + delete _brokers[broker.subscription.id]; + } + function _unsubscribeBroker(broker) { - _session.unsubscribe(broker.subscription); + var defer = $q.defer(); + + _session.unsubscribe(broker.subscription) + .then(_resolveBroker, defer.reject); + + return defer.promise; + + function _resolveBroker() { + defer.resolve(broker); + } + } function _unsubscribeAllBrokers() { diff --git a/dist/ngAutobahn.min.js b/dist/ngAutobahn.min.js index 9c65efd..3199e43 100644 --- a/dist/ngAutobahn.min.js +++ b/dist/ngAutobahn.min.js @@ -1 +1 @@ -!function(a){"use strict";a.module("ngAutobahn.connection",[]).constant("NG_AUTOBAHN_CONNECTION_STATUS",{OPENED:"ngAutobahn.connection.state.opened",CLOSED:"ngAutobahn.connection.state.closed",LOST:"ngAutobahn.connection.state.lost"}).constant("NG_AUTOBAHN_CONNECTION_EVENTS",{OPEN:"ngAutobahn.connection.open",CLOSE:"ngAutobahn.connection.close",LOST:"ngAutobahn.connection.lost"}).provider("ngAutobahnConnection",[function(){var b={},c={mockMode:!1,url:null,realm:null,retries:{max:100,initialDelay:3,delayGrowthFactor:1.5,maxDelay:300,delayJitter:.1}};this.configure=function(d){a.extend(c,d),b={url:c.url,realm:c.realm,max_retries:c.retries.max,initial_retry_delay:c.retries.initialDelay,retry_delay_growth:c.retries.delayGrowthFactor,max_retry_delay:c.retries.maxDelay,retry_delay_jitter:c.retries.delayJitter}},this.$get=["$q","$rootScope","NG_AUTOBAHN_CONNECTION_STATUS","NG_AUTOBAHN_CONNECTION_EVENTS",function(a,c,d,e){function f(){function f(){var c=a.defer();return q?(c.resolve(p),l()):(q=new autobahn.Connection(b),q.onopen=function(a){p=a,c.resolve(a),l()},q.onclose=function(a){c.reject(),j()},q.open()),c.promise}function g(){return h().then(k)}function h(){var b=a.defer();return q?(q.onclose=function(a){q=null,b.resolve()},q.close()):b.reject(),b.promise}function i(){j(),h().then(f)}function j(){s=d.LOST,o()}function k(){s=d.CLOSED,n()}function l(){s=d.OPENED,m()}function m(){c.$broadcast(e.OPEN,p)}function n(a){c.$broadcast(e.CLOSE,a)}function o(a){c.$broadcast(e.LOST,a)}var p,q,r=this,s=d.CLOSED;r.openConnection=f,r.closeConnection=g,r.resetConnection=i,Object.defineProperty(r,"status",{get:function(){return s}}),Object.defineProperty(r,"isOpen",{get:function(){return s===d.OPENED}}),Object.defineProperty(r,"isClosed",{get:function(){return s===d.CLOSED}}),Object.defineProperty(r,"isLost",{get:function(){return s===d.LOST}})}return new f}]}])}(angular),function(a){"use strict";a.module("ngAutobahn.messageBroker",[]).factory("NgAutobahnMessageBroker",["$rootScope",function(a){function b(b,c){function d(a,b){k[a]||(k[a]=[]),k[a].push(b)}function e(a,b){return c(j,a,b)}function f(){return j}function g(b,c){var d=c.channel,e=c.type,f=c.data;h(d,e)&&(i(e,f),a.$applyAsync())}function h(a,b){return j===a&&k[b]}function i(a,b){for(var c=k[a],d=0;d