ember-pusher
ember-pusher copied to clipboard
Uncaught TypeError: this.pusher.channelFor is not a function [Component Use]
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?
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'));
Hey @csprocket777, thanks for the report. I'll investigate!
Was this ever fixed?