-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngUnsubscribe takes too long #7
Comments
Hi Patrick! some q's - Is this network time related? |
so this is instant c.ngUnsubscribe = function(args) {
console.time('ngUnsubscribe');
// var cpos;
// cpos = c['_channels'].indexOf(args.channel);
// if (cpos !== -1) {
// c['_channels'].splice(cpos, 1);
// }
// c['_presence'][args.channel] = null;
// delete $rootScope.$$listeners[c.ngMsgEv(args.channel)];
// delete $rootScope.$$listeners[c.ngPrsEv(args.channel)];
return window.PUBNUB.unsubscribe(args, function() {
console.timeEnd('ngUnsubscribe');
});
}; while the original code isn't https://github.com/pubnub/pubnub-angular/blob/master/lib/pubnub-angular.js#L144 c.ngUnsubscribe = function(args) {
console.time('ngUnsubscribe');
// var cpos;
// cpos = c['_channels'].indexOf(args.channel);
// if (cpos !== -1) {
// c['_channels'].splice(cpos, 1);
// }
// c['_presence'][args.channel] = null;
// delete $rootScope.$$listeners[c.ngMsgEv(args.channel)];
// delete $rootScope.$$listeners[c.ngPrsEv(args.channel)];
return c.jsapi.unsubscribe(args, function() {
console.timeEnd('ngUnsubscribe');
});
}; the only thing I can think of is whatever this is trying to do https://github.com/pubnub/pubnub-angular/blob/master/lib/pubnub-angular.js#L15 _ref = ['map', 'each'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
k = _ref[_i];
if ((typeof PUBNUB !== "undefined" && PUBNUB !== null ? PUBNUB[k] : void 0) instanceof Function) {
(function(kk) {
return c[kk] = function() {
var _ref1;
return (_ref1 = c['_instance']) != null ? _ref1[kk].apply(c['_instance'], arguments) : void 0;
};
})(k);
}
}
for (k in PUBNUB) {
if ((typeof PUBNUB !== "undefined" && PUBNUB !== null ? PUBNUB[k] : void 0) instanceof Function) {
(function(kk) {
return c['jsapi'][kk] = function() {
var _ref1;
return (_ref1 = c['_instance']) != null ? _ref1[kk].apply(c['_instance'], arguments) : void 0;
};
})(k);
}
} |
👍 |
@gdi2290 if you're using angular, you shouldn't be referencing PUBNUB - the Angular library exposes all direct methods via PubNub.jsapi.*, where * is the regular JS methods. I have a feeling that your method is fast because the window.PUBNUB is not really connected, as Stephen alludes to... I just created a codepen where you should be able to see what's going on: http://codepen.io/sunnygleason/pen/FIiDs?editors=100 My performance looks like this...
What do you see? |
I updated the codepen
the problem is most likely network time related as Stephen suggested. I can investigate this a little more later since hanging only in my app |
I found the problem, but the issue should be submitted on the PubNub javascript repo. The problems turns out to be synchronous xhr calls for presence events (Leave). Initializing pubnub with xdr({
blocking : blocking || SSL, In the example I forgot to add |
ngUnsubscribe has poor performance compared to
window.PUBNUB.unsubscribe()
The text was updated successfully, but these errors were encountered: