gilgen / ember-pusher

A proper Ember / Pusher integration.
MIT License
100 stars 35 forks source link

Added option to dasherize channel names, including some tests #17

Closed malrase closed 9 years ago

malrase commented 9 years ago

In some cases, Pusher requires a channel name that includes a dash – for example in presence- or private- channels. Due to ember-cli being very strict with JavaScript syntax, it is not possible to use a dash in the channel names when configuring your PUSHER_SUBSCRIPTIONS.

To get around this, we allow the PUSHER_OPTS option of dasherizeChannel. When set to true, the channel name in PUSHER_SUBSCRIPTIONS is dasherized. For instance, this is how you would build a simple presence controller.

PUSHER_OPTS: { key: 'foo', dasherizeChannel: true }

...
var YourController = Em.Controller.extend(EmberPusher.Bindings, {
  PUSHER_SUBSCRIPTIONS: {
    presenceMessages: ['member_added'],
  },
});

Added tests and updated the README to include this option.

gilgen commented 9 years ago

Hey @malrase, thanks for the PR, this shouldn't actually be required though. You could use the key name as a string in the object if it has dashes.

  PUSHER_SUBSCRIPTIONS: {
    "presence-messages": ['member_added'],
  }
malrase commented 9 years ago

Sigh, I'm an idiot.

Thanks for your kind reply!