2014-08-29 100 views
2

在餘燼項目中推動器。我很抱歉,但我發現如果很難讓我的頭繞着JS工具。如何在餘燼項目中使用餘燼推動器

Ember pusher github

這樣做的步驟。

  1. 內部餘燼-CLI項目:亭子安裝--save推杆
  2. 在broccoli.js文件添加的行:app.import( '銷售商/推杆/ DIST/pusher.js'); 在.jshintrc

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

  1. 然後從git mentioned link複製餘燼-pusher.amd.js並保存在/供應商的文件夾中。

  2. 在broccoli.js文件添加的行:

    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.在application.js中控制器

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'); 
      } 
     } 
    }); 

我DONOT得到任何錯誤消息,但推儀表盤不顯示任何連接

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

回答

1

這裏就是我做得到它的工作:

  1. bower install --save pusher
  2. https://github.com/jamiebikies/ember-pusher#download
  3. 下載ember-pusher.jsvendor/ember-pusher/ember-pusher.js以下內容添加到您的Brocfile.js

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

  4. 添加以下config/environment.js

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

  5. 日誌事件Ø你的控制器的NE

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