diff --git a/bower.json b/bower.json index ba6cbfc..1afc2fe 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wamp", - "version": "0.2.1", + "version": "0.3.0", "main": "./release/angular-wamp.js", "authors": [ "David Dan " @@ -24,7 +24,7 @@ "tests" ], "dependencies": { - "angular": "^1.2.0", + "angular": "^1.3.0", "autobahn": ">= 0.9.5" } } diff --git a/package.json b/package.json index 6491879..1dc7cb4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wamp", "description": "Angular library for Autobahn.js (WAMP v2)", - "version": "0.2.1", + "version": "0.3.0", "author": "David Dan ", "homepage": "https://github.com/voryx/angular-wamp", "repository": { @@ -31,7 +31,7 @@ "url": "https://github.com/voryx/angular-wamp/issues" }, "dependencies": { - "angular": "^1.2.0", + "angular": "^1.3.0", "autobahn": ">= 0.9.5" }, "license": "MIT", diff --git a/release/angular-wamp.js b/release/angular-wamp.js index 075c306..5134899 100644 --- a/release/angular-wamp.js +++ b/release/angular-wamp.js @@ -235,7 +235,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex return function () { var cb = func.apply(this, arguments); - $rootScope.$apply(); + $rootScope.$applyAsync(); return cb; }; } diff --git a/release/angular-wamp.min.js b/release/angular-wamp.min.js index 0424c7f..7ea85fe 100644 --- a/release/angular-wamp.min.js +++ b/release/angular-wamp.min.js @@ -1 +1 @@ -if("undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports){var autobahn=require("autobahn");module.exports="vxWamp"}!function(){"use strict";function a(){var a;this.init=function(b){a=b||{}};var b=this.interceptors=[];return this.$get=["$rootScope","$q","$log","$injector",function(c,d,e,f){function g(b){return a.disable_digest&&a.disable_digest===!0?b:function(){var a=b.apply(this,arguments);return c.$apply(),a}}var h,i=d.defer(),j=i.promise,k=a.prefix||"$wamp",l=function(a,b,e){var f=d.defer();return c.$broadcast(k+".onchallenge",{promise:f,session:a,method:b,extra:e}),f.promise},m={onchallenge:g(l),use_deferred:d.defer};a=angular.extend(m,a);var n=[];angular.forEach(b,function(a){n.unshift(angular.isString(a)?f.get(a):f.invoke(a))}),h=new autobahn.Connection(a),h.onopen=g(function(a,b){e.debug("Congrats! You're connected to the WAMP server!"),c.$broadcast(k+".open",{session:a,details:b}),i.resolve()}),h.onclose=g(function(a,b){e.debug("Connection Closed: ",a,b);for(var d in h.session._call_reqs)if(h.session._call_reqs.hasOwnProperty(d)){var f=new Error("Connection Closed"),g=h.session._call_reqs[d];g[0].reject(f)}c.$broadcast(k+".close",{reason:a,details:b})});var o=function(a,b,e,f){var i,j,l={},m=d.defer();return b=g(b),j=function(){var c=h.session.subscribe(a,b,e).then(function(a){return l.hasOwnProperty("id")&&delete l.id,l=angular.extend(a,l),m.resolve(l),a});f&&f(c)},h.isOpen&&j(),i=c.$on(k+".open",j),l.promise=m.promise,l.unsubscribe=function(){return i(),h.session.unsubscribe(l)},l.promise},p=function(a,b,c){var f=function(c){return{result:c,type:a,args:b}},g=function(c){return e.error(k+" error",{type:a,arguments:b,error:c}),d.reject({error:c,type:a,args:b})},h=j.then(function(){return c()}),i=[f,g];for(angular.forEach(n,function(b){(b[a+"Response"]||b[a+"ResponseError"])&&i.push(b[a+"Response"],b[a+"ResponseError"])}),i.push(function(a){return a.result},function(a){return d.reject(a.error)});i.length;){var l=i.shift(),m=i.shift();h=h.then(l,m)}return h};return{connection:h,open:function(){a.authmethods&&-1!==a.authmethods.indexOf("wampcra")&&!a.authid?e.debug("You're using WAMP CRA. The authid must be set on $wamp before the connection can be opened, ie: $wamp.setAuthId('john.doe')"):h.open()},setAuthId:function(b,c){a.authid=b,c&&h.open()},close:function(){h.close()},subscribe:function(a,b,c,d){return p("subscribe",arguments,function(){return o(a,b,c,d)})},subscribeOnScope:function(a,b,c){return this.subscribe(b,c).then(function(b){a.$on("$destroy",function(){return b.unsubscribe()})})},unsubscribe:function(a){return p("unsubscribe",arguments,function(){return a.unsubscribe()})},publish:function(a,b,c,d){return p("publish",arguments,function(){return h.session.publish(a,b,c,d)})},register:function(a,b,c){return b=g(b),p("register",arguments,function(){return h.session.register(a,b,c)})},unregister:function(a){return p("unregister",arguments,function(){return a.unregister()})},call:function(a,b,c,d){return p("call",arguments,function(){return h.session.call(a,b,c,d)})}}}],this}angular.module("vxWamp",[]).provider("$wamp",a)}(); \ No newline at end of file +if("undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports){var autobahn=require("autobahn");module.exports="vxWamp"}!function(){"use strict";function a(){var a;this.init=function(b){a=b||{}};var b=this.interceptors=[];return this.$get=["$rootScope","$q","$log","$injector",function(c,d,e,f){function g(b){return a.disable_digest&&a.disable_digest===!0?b:function(){var a=b.apply(this,arguments);return c.$applyAsync(),a}}var h,i=d.defer(),j=i.promise,k=a.prefix||"$wamp",l=function(a,b,e){var f=d.defer();return c.$broadcast(k+".onchallenge",{promise:f,session:a,method:b,extra:e}),f.promise},m={onchallenge:g(l),use_deferred:d.defer};a=angular.extend(m,a);var n=[];angular.forEach(b,function(a){n.unshift(angular.isString(a)?f.get(a):f.invoke(a))}),h=new autobahn.Connection(a),h.onopen=g(function(a,b){e.debug("Congrats! You're connected to the WAMP server!"),c.$broadcast(k+".open",{session:a,details:b}),i.resolve()}),h.onclose=g(function(a,b){e.debug("Connection Closed: ",a,b);for(var d in h.session._call_reqs)if(h.session._call_reqs.hasOwnProperty(d)){var f=new Error("Connection Closed"),g=h.session._call_reqs[d];g[0].reject(f)}c.$broadcast(k+".close",{reason:a,details:b})});var o=function(a,b,e,f){var i,j,l={},m=d.defer();return b=g(b),j=function(){var c=h.session.subscribe(a,b,e).then(function(a){return l.hasOwnProperty("id")&&delete l.id,l=angular.extend(a,l),m.resolve(l),a});f&&f(c)},h.isOpen&&j(),i=c.$on(k+".open",j),l.promise=m.promise,l.unsubscribe=function(){return i(),h.session.unsubscribe(l)},l.promise},p=function(a,b,c){var f=function(c){return{result:c,type:a,args:b}},g=function(c){return e.error(k+" error",{type:a,arguments:b,error:c}),d.reject({error:c,type:a,args:b})},h=j.then(function(){return c()}),i=[f,g];for(angular.forEach(n,function(b){(b[a+"Response"]||b[a+"ResponseError"])&&i.push(b[a+"Response"],b[a+"ResponseError"])}),i.push(function(a){return a.result},function(a){return d.reject(a.error)});i.length;){var l=i.shift(),m=i.shift();h=h.then(l,m)}return h};return{connection:h,open:function(){a.authmethods&&-1!==a.authmethods.indexOf("wampcra")&&!a.authid?e.debug("You're using WAMP CRA. The authid must be set on $wamp before the connection can be opened, ie: $wamp.setAuthId('john.doe')"):h.open()},setAuthId:function(b,c){a.authid=b,c&&h.open()},close:function(){h.close()},subscribe:function(a,b,c,d){return p("subscribe",arguments,function(){return o(a,b,c,d)})},subscribeOnScope:function(a,b,c){return this.subscribe(b,c).then(function(b){a.$on("$destroy",function(){return b.unsubscribe()})})},unsubscribe:function(a){return p("unsubscribe",arguments,function(){return a.unsubscribe()})},publish:function(a,b,c,d){return p("publish",arguments,function(){return h.session.publish(a,b,c,d)})},register:function(a,b,c){return b=g(b),p("register",arguments,function(){return h.session.register(a,b,c)})},unregister:function(a){return p("unregister",arguments,function(){return a.unregister()})},call:function(a,b,c,d){return p("call",arguments,function(){return h.session.call(a,b,c,d)})}}}],this}angular.module("vxWamp",[]).provider("$wamp",a)}(); \ No newline at end of file diff --git a/src/angular-wamp.js b/src/angular-wamp.js index a5bf12f..fa5619f 100644 --- a/src/angular-wamp.js +++ b/src/angular-wamp.js @@ -235,7 +235,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex return function () { var cb = func.apply(this, arguments); - $rootScope.$apply(); + $rootScope.$applyAsync(); return cb; }; }