Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-phoenix

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-phoenix - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

bower.json
{
"name": "angular-phoenix",
"version": "0.2.0",
"version": "0.2.1",
"authors": [

@@ -5,0 +5,0 @@ "MikaAK <mikakalathil@gmail.com>"

'use strict';
angular.module('angular-phoenix', []).value('PhoenixBase', window.Phoenix).provider('Phoenix', function () {
var urlBase = '/ws',
_autoJoinSocket = true;
angular.module('angular-phoenix', []).factory('PhoenixBase', ['$rootScope', function ($rootScope) {
var phoenix = angular.copy(window.Phoenix);
this.setUrl = function (url) {
return urlBase = url;
};
this.setAutoJoin = function (bool) {
return _autoJoinSocket = bool;
};
phoenix.Channel.prototype.on = (function () {
var _oldOn = angular.copy(phoenix.Channel.prototype.on);
this.$get = ['$rootScope', '$window', 'PhoenixBase', function ($rootScope, $window, PhoenixBase) {
var socket = new PhoenixBase.Socket(urlBase),
channels = new Map(),
helpers = {
_extendChannel: function _extendChannel(channel) {
var phoenixReplace = {
on: function on(scope, event, callback) {
var _this = this;
return function on(scope, event, callback) {
var _this = this;
if (typeof scope === 'string') {
callback = event;
event = scope;
scope = null;
}
var newCallback;
this.bindings.push({ event: event, callback: (function (_callback) {
function callback(_x) {
return _callback.apply(this, arguments);
}
if (typeof scope === 'string') {
callback = event;
event = scope;
scope = null;
}
callback.toString = function () {
return _callback.toString();
};
newCallback = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return callback;
})(function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
callback.apply(undefined, args);
$rootScope.$apply();
};
callback.apply(undefined, args);
$rootScope.$apply();
}) });
_oldOn.call(this, event, newCallback);
if (scope) scope.$on('$destroy', function () {
return _this.bindings.splice(callback, 1);
});
}
};
if (scope) scope.$on('$destroy', function () {
return _this.bindings.splice(newCallback, 1);
});
};
})();
return angular.extend(channel, phoenixReplace);
},
phoenix.Channel.prototype.receive = (function () {
var _oldReceive = angular.copy(phoenix.Channel.prototype.receive);
joinChannel: function joinChannel(name, message) {
var joinRes,
promise,
channel = channels.get(name);
return function receive(status, callback) {
if (typeof status === 'function') {
callback = status;
status = null;
}
joinRes = function (resolve, reject) {
channel = socket.join(name, message);
if (!status) status = 'ok';
channel.receive = (function () {
var _oldReceive = angular.copy(channel.receive);
return _oldReceive.call(this, status, callback);
};
})();
return function receive(status, callback) {
if (typeof status === 'function') {
callback = status;
status = null;
}
phoenix.Channel.prototype.push = (function () {
var _oldPush = angular.copy(phoenix.Channel.prototype.push);
if (!status) status = 'ok';
return function push() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
_oldReceive.call(this, status, function (chan) {
return callback(helpers._extendChannel(chan));
});
};
})();
var res = _oldPush.apply(this, args);
channels.set(name, { status: 'fetching', channel: channel });
res.receive = (function () {
var oldRecieve = res.receive;
channel.after(5000, reject).receive(function (chan) {
return resolve(chan);
});
return function receive(status, callback) {
if (typeof status === 'function') {
callback = status;
status = null;
}
if (!status) status = 'ok';
return oldRecieve.call(this, status, callback);
};
})();
promise = new Promise(joinRes);
return res;
};
})();
promise.then(function () {
channels.set(name, { status: 'connected', channel: channel, promise: promise });
return phoenix;
}]).provider('Phoenix', function () {
var urlBase = '/ws',
_autoJoinSocket = true;
this.setUrl = function (url) {
return urlBase = url;
};
this.setAutoJoin = function (bool) {
return _autoJoinSocket = bool;
};
this.$get = ['PhoenixBase', function (PhoenixBase) {
var socket = new PhoenixBase.Socket(urlBase),
channels = new Map(),
joinChannel = function joinChannel(name, message) {
var joinRes,
promise,
channel = channels.get(name);
joinRes = function (resolve, reject) {
channel = socket.join(name, message);
channels.set(name, { status: 'fetching', channel: channel });
channel.after(5000, reject).receive(function (chan) {
return resolve(chan);
});
};
return angular.extend(channel, { promise: promise });
}
promise = new Promise(joinRes);
promise.then(function () {
channels.set(name, { status: 'connected', channel: channel, promise: promise });
});
return angular.extend(channel, { promise: promise });
};

@@ -121,3 +142,3 @@

return channel.channel;
}return helpers.joinChannel(name, message);
}return joinChannel(name, message);
}

@@ -124,0 +145,0 @@ };

{
"name": "angular-phoenix",
"version": "0.2.0",
"version": "0.2.1",
"description": "Native bindings for phoenix in angular",

@@ -5,0 +5,0 @@ "main": "dist/angular-phoenix.js",

'use strict'
angular.module('angular-phoenix', [])
.value('PhoenixBase', window.Phoenix)
.provider('Phoenix', function() {
var urlBase = '/ws',
_autoJoinSocket = true
.factory('PhoenixBase', ['$rootScope', ($rootScope) => {
var phoenix = angular.copy(window.Phoenix)
this.setUrl = url => urlBase = url
this.setAutoJoin = bool => _autoJoinSocket = bool
phoenix.Channel.prototype.on = (() => {
var _oldOn = angular.copy(phoenix.Channel.prototype.on)
this.$get = ['$rootScope', '$window', 'PhoenixBase', ($rootScope, $window, PhoenixBase) => {
var socket = new PhoenixBase.Socket(urlBase),
channels = new Map(),
helpers = {
_extendChannel(channel) {
var phoenixReplace = {
on(scope, event, callback) {
if (typeof scope === 'string') {
callback = event
event = scope
scope = null
}
return function on(scope, event, callback) {
var newCallback
this.bindings.push({event, callback: (...args) => {
callback(...args)
$rootScope.$apply()
}})
if (typeof scope === 'string') {
callback = event
event = scope
scope = null
}
if (scope)
scope.$on('$destroy', () => this.bindings.splice(callback, 1))
newCallback = (...args) => {
callback(...args)
$rootScope.$apply()
}
_oldOn.call(this, event, newCallback)
if (scope)
scope.$on('$destroy', () => this.bindings.splice(newCallback, 1))
}
})();
phoenix.Channel.prototype.receive = (() => {
var _oldReceive = angular.copy(phoenix.Channel.prototype.receive)
return function receive(status, callback) {
if (typeof status === 'function') {
callback = status
status = null
}
if (!status)
status = 'ok'
return _oldReceive.call(this, status, callback)
}
})();
phoenix.Channel.prototype.push = (() => {
var _oldPush = angular.copy(phoenix.Channel.prototype.push)
return function push(...args) {
var res = _oldPush.apply(this, args)
res.receive = (() => {
var oldRecieve = (res.receive)
return function receive(status, callback) {
if (typeof status === 'function') {
callback = status
status = null
}
if (!status)
status = 'ok'
return oldRecieve.call(this, status, callback)
}
})();
return angular.extend(channel, phoenixReplace)
},
return res
}
})();
joinChannel(name, message) {
var joinRes,
promise,
channel = channels.get(name)
return phoenix
}])
joinRes = (resolve, reject) => {
channel = socket.join(name, message)
.provider('Phoenix', function() {
var urlBase = '/ws',
_autoJoinSocket = true
channel.receive = (() => {
var _oldReceive = angular.copy(channel.receive)
this.setUrl = url => urlBase = url
this.setAutoJoin = bool => _autoJoinSocket = bool
return function receive(status, callback) {
if (typeof status === 'function') {
callback = status
status = null
}
this.$get = ['PhoenixBase', (PhoenixBase) => {
var socket = new PhoenixBase.Socket(urlBase),
channels = new Map(),
joinChannel= (name, message) => {
var joinRes,
promise,
channel = channels.get(name)
if (!status)
status = 'ok'
joinRes = (resolve, reject) => {
channel = socket.join(name, message)
_oldReceive.call(this, status, chan => callback(helpers._extendChannel(chan)))
}
})();
channels.set(name, {status: 'fetching', channel})
channels.set(name, {status: 'fetching', channel})
channel
.after(5000, reject)
.receive((chan) => resolve(chan))
}
channel
.after(5000, reject)
.receive((chan) => resolve(chan))
}
promise = new Promise(joinRes)
promise = new Promise(joinRes)
promise
.then(() => {
channels.set(name, {status: 'connected', channel, promise})
})
promise
.then(() => {
channels.set(name, {status: 'connected', channel, promise})
})
return angular.extend(channel, {promise})
}
return angular.extend(channel, {promise})
}
}
if (_autoJoinSocket)

@@ -107,3 +138,3 @@ socket.connect()

return helpers.joinChannel(name, message)
return joinChannel(name, message)
}

@@ -110,0 +141,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc