angular-phoenix
Advanced tools
Comparing version 0.2.4 to 0.2.5-rc.2
{ | ||
"name": "angular-phoenix", | ||
"version": "0.2.4", | ||
"version": "0.2.5-rc.2", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "MikaAK <mikakalathil@gmail.com>" |
@@ -32,3 +32,3 @@ 'use strict'; | ||
if (scope) scope.$on('$destroy', function () { | ||
return _this.bindings.splice(newCallback, 1); | ||
return _this.off(event); | ||
}); | ||
@@ -64,3 +64,3 @@ }; | ||
res.receive = (function () { | ||
var oldRecieve = res.receive; | ||
var oldRecieve = angular.copy(res.receive); | ||
@@ -146,6 +146,13 @@ return function receive(status, callback) { | ||
join: function join(name) { | ||
var message = arguments[1] === undefined ? {} : arguments[1]; | ||
join: function join(scope, name) { | ||
var message = arguments[2] === undefined ? {} : arguments[2]; | ||
var channel = channels.get(name), | ||
if (typeof scope === 'string') { | ||
message = name; | ||
name = scope; | ||
scope = null; | ||
} | ||
var resChannel, | ||
channel = channels.get(name), | ||
status = channel && channel.status; | ||
@@ -157,3 +164,11 @@ | ||
return channel.channel; | ||
}return joinChannel(name, message); | ||
}resChannel = joinChannel(name, message); | ||
if (scope) resChannel.promise.then(function (chan) { | ||
scope.$on('$destroy', function () { | ||
return chan.leave(); | ||
}); | ||
}); | ||
return resChannel; | ||
} | ||
@@ -160,0 +175,0 @@ }; |
{ | ||
"name": "angular-phoenix", | ||
"version": "0.2.4", | ||
"version": "0.2.5-rc.2", | ||
"description": "Native bindings for phoenix in angular", | ||
@@ -5,0 +5,0 @@ "main": "dist/angular-phoenix.js", |
@@ -14,4 +14,2 @@ Angular Phoenix | ||
**__Note:__** You must have the original `phoenix.js` loaded prior to this, it also makes use of promises so please have a promise library loaded or be using ES6! | ||
### How to use | ||
@@ -78,2 +76,6 @@ This is incomplete and only allows for a single socket connection per client | ||
}) | ||
// Pass the current scope in so that when destroyed | ||
// the channel is left | ||
Phoenix.join(scope, 'chatRoom:lobby', user) | ||
} | ||
@@ -80,0 +82,0 @@ ``` |
@@ -27,3 +27,3 @@ 'use strict' | ||
if (scope) | ||
scope.$on('$destroy', () => this.bindings.splice(newCallback, 1)) | ||
scope.$on('$destroy', () => this.off(event)) | ||
} | ||
@@ -55,3 +55,3 @@ })(); | ||
res.receive = (() => { | ||
var oldRecieve = (res.receive) | ||
var oldRecieve = angular.copy(res.receive) | ||
@@ -138,4 +138,11 @@ return function receive(status, callback) { | ||
join(name, message = {}) { | ||
var channel = channels.get(name), | ||
join(scope, name, message = {}) { | ||
if (typeof scope === 'string') { | ||
message = name | ||
name = scope | ||
scope = null | ||
} | ||
var resChannel, | ||
channel = channels.get(name), | ||
status = channel && channel.status | ||
@@ -152,3 +159,11 @@ | ||
return joinChannel(name, message) | ||
resChannel = joinChannel(name, message) | ||
if (scope) | ||
resChannel.promise | ||
.then((chan) => { | ||
scope.$on('$destroy', () => chan.leave()) | ||
}) | ||
return resChannel | ||
} | ||
@@ -155,0 +170,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14402
284
90