推动ember-cli项目。对不起,我发现如果难以理解js工具。
这样做的步骤。
"predef": {
"document": true,
"window": true,
"MyappENV": true,
"Pusher": true
}
然后从git mentioned link复制了ember-pusher.amd.js并保存在/ vendor文件夹中。
在broccoli.js文件中添加了一行:
var App = Ember.Application.extend({
modulePrefix: 'Myapp', // TODO: loaded via config
Resolver: Resolver,
PUSHER_OPTS: {
key: '586f8kjhfkdf8d7f9',
connection: {},
logAllEvents: true
},
});
5.在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');
}
}
});
我没有收到任何错误消息,但推送仪表板没有显示任何连接
app.import('vendor/ember-pusher/ember-pusher.amd.js', {
exports: {
'ember-pusher': [
'controller',
'binding',
'clientevents',
'initialize'
]
}
});
答案 0 :(得分:4)
现在有一个ember插件,自述文件中有说明:https://github.com/ivanvotti/ember-cli-pusher
答案 1 :(得分:1)
这是我为了让它发挥作用所做的事情:
ember-pusher.js
至vendor/ember-pusher/ember-pusher.js
将以下内容添加到Brocfile.js
app.import('bower_components/pusher/dist/pusher.js');
app.import('vendor/ember-pusher/ember-pusher.js');
将以下内容添加到config/environment.js
ENV.APP.PUSHER_OPTS = { key: 'your-app-key', connection: { } }
记录来自其中一个控制器的事件
import Ember from 'ember';
export default Ember.Controller.extend(EmberPusher.Bindings, {
logPusherEvents: true,
PUSHER_SUBSCRIPTIONS: {
myChannel: ['my-event']
}
}