2
votes

pusher in ember-cli project. I am sorry but i find if difficult to get my head around js tools.

Ember pusher github

steps done so for.

  1. Inside ember-cli project: bower install --save pusher
  2. In broccoli.js file added line: app.import('vendor/pusher/dist/pusher.js'); in .jshintrc

"predef": { "document": true, "window": true, "MyappENV": true, "Pusher": true }

  1. Then copied ember-pusher.amd.js from git mentioned link and saved in /vendor folder.

  2. In broccoli.js file added line:

    var App = Ember.Application.extend({ modulePrefix: 'Myapp', // TODO: loaded via config Resolver: Resolver, PUSHER_OPTS: { key: '586f8kjhfkdf8d7f9', connection: {}, logAllEvents: true }, });

5.In app.js.

var App = Ember.Application.extend({ modulePrefix: 'Myapp', Resolver: Resolver, PUSHER_OPTS: { key: '586f8kjhfkdf8d7f9', connection: {}, logAllEvents: true } }); 6. In application.js controller

 import Ember from 'ember';
  export
  default Ember.Controller.extend({
      PUSHER_SUBSCRIPTIONS: {
          myChannel: ['my-event']
      },
      actions: {
          myEvent: function () {
              console.log('Event my event was triggered xxxxxxxxxxxxxxxxxxx');
          }
      }
  });

I donot get any error message but pusher dashboard does not show any connections

   app.import('vendor/ember-pusher/ember-pusher.amd.js', {
     exports: {
         'ember-pusher': [
             'controller',
             'binding',
             'clientevents',
             'initialize'
         ]
     }
 });
2

2 Answers

4
votes

There is now an ember addon for this, with instructions in the README: https://github.com/ivanvotti/ember-cli-pusher

1
votes

Here's what I did to get it working:

  1. bower install --save pusher
  2. Download ember-pusher.js to vendor/ember-pusher/ember-pusher.js from https://github.com/jamiebikies/ember-pusher#download
  3. Add the following to your Brocfile.js

    app.import('bower_components/pusher/dist/pusher.js'); app.import('vendor/ember-pusher/ember-pusher.js');

  4. Add the following to config/environment.js

    ENV.APP.PUSHER_OPTS = { key: 'your-app-key', connection: { } }

  5. Log events from one of your controllers

    import Ember from 'ember'; export default Ember.Controller.extend(EmberPusher.Bindings, { logPusherEvents: true, PUSHER_SUBSCRIPTIONS: { myChannel: ['my-event'] } }