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

Uncaught TypeError: this.pusher.channelFor is not a function [Component Use]

Open csprocket777 opened this issue 8 years ago • 3 comments

When extending controllers with EmberPusher.ClientEvents, I can trigger events like this with no problem:

this.pusherTrigger('channelName', 'client-test-event', {foo:1});

However, when I extend a component with EmberPusher.ClientEvents, I get the following error:

Uncaught TypeError: this.pusher.channelFor is not a function

It seems that this.pusher loses 'channelFor' when extending from a component.

Any ideas?

csprocket777 avatar Aug 17 '16 14:08 csprocket777

I have a temporary hack for this, and that is to pass in the pusher instance in the pusherTrigger call. Like this:

/* addon/mixins/client-events.js */
pusherTrigger(channelName, eventName, data, pusherInstance) {
    let channel = pusherInstance ? pusherInstance.channelFor(channelName) : this.pusher.channelFor(channelName);
    channel.trigger(eventName, data);
  }

then use it from the component like this:

this.pusherTrigger(this.get('channelName'), 'client-activity-change', this.get('currentActivity'), this.get('pusher'));

csprocket777 avatar Aug 17 '16 14:08 csprocket777

Hey @csprocket777, thanks for the report. I'll investigate!

gilgen avatar Aug 17 '16 14:08 gilgen

Was this ever fixed?

tsnevillecom avatar May 11 '18 12:05 tsnevillecom