pusher-angular icon indicating copy to clipboard operation
pusher-angular copied to clipboard

binding to a event on a channel does not pass the context

Open hworang opened this issue 10 years ago • 1 comments

Hi, when binding to event on a channel or pusher the context is not set correctly. Within the bind function at the channel and the pusher level the decoratedCallback is used to signal changes to angular however you are not executing the callback with any context. I am using this with the latest pusher version.

bind: function (eventName, callback, context) {
        var decoratedCallback = function (data) {
          callback(data); //This with the latest version of pusher does not use the context set.
                         // callback.call(this,data); looks like it will fix it. the same correction is required at the pusher
          $rootScope.$digest();
        };
        this.client.bind(eventName, decoratedCallback, context);
        return decoratedCallback;
      },

Please could you take a look.

thanks,

hworang avatar Dec 01 '15 11:12 hworang

Yep, you seem to be correct. Do you fancy making a pull request? Otherwise I will try to get to this some time soon.

hamchapman avatar Dec 03 '15 16:12 hamchapman