1.3.0 • Published 9 years ago

ember-pusher-guru v1.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Build Status Ember Observer Score npm version

Ember-pusher-guru

Ember addon for easy integration with Pusher

Advantages

  • mechanism of integration is based on Ember.Evented
  • addon is a mixin which is easy to include

Installation

ember install ember-pusher-guru

Configuration

Set pusherKey value in environment:

// my-project/config/environment.js
  var ENV = {
    pusherKey: '49482as87s88s6d9sw74',
    ...

And extend security policy rule:

contentSecurityPolicy: {
  'connect-src': "'self' ws://ws.pusherapp.com"
}

Then you need to add this line:

<script type="text/javascript">window.ALLOW_PUSHER_OVERRIDE = true;</script>

to your tests/index.html right after the body tag. This will allow pusher-test-stub to work and run your tests.

Usage

You need to create service which must be extended from pusher-base service:

# my-project/services/pusher.js

import Pusher from 'ember-pusher-guru/services/pusher-base';

export default Pusher.extend({
  authEndpoint: 'http://backend.com/auth' // optional (for authentication)
  channelsData: [
    { channelName1: ['eventName1'] },
    { channelName2: ['eventName2', 'eventName3'] }
    ...
  ]
});

You can create it as you want, but pusher is default.

And then use pusher-initializer mixin wherever you want and define connection events to method via pusherActions

import PusherInitializer from 'ember-pusher-guru/mixins/pusher-initializer';

export default Ember.Route.extend(PusherInitializer, {
  // if you named your pusher service otherwise you need to inject it under the name `pusher`
  // pusher: Ember.inject.service('my-pusher-service-name'),

  pusherActions: [
    { eventName: 'methodName' },
    { event2name: 'method2name' }
  ],

  methodName() {
    // code
  }
});
1.3.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago