/
initializer.js
38 lines (26 loc) · 1.06 KB
/
initializer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Controller } from "./controller";
var global = (typeof window !== 'undefined') ? window : {},
Ember = global.Ember,
Pusher = global.Pusher;
function initialize() {
if(!Ember) { throw("Include Ember before EmberPusher"); }
if(!Pusher) { throw("Include Pusher before EmberPusher"); }
Ember.Application.initializer({
name: "pusherConnected",
initialize: function(container, application) {
var pusherController, options, pusher, dict;
dict = 'pusher:main';
container.register(dict, Controller);
pusherController = container.lookup(dict);
options = application.PUSHER_OPTS;
Ember.assert("You need to provide PUSHER_OPTS on your application", options);
Ember.assert("You need to include the pusher libraries", Pusher);
pusher = new Pusher(options.key, options.connection);
pusherController.didCreatePusher(pusher);
console.log('totes injected');
application.inject('controller', 'pusher', dict);
application.inject('route', 'pusher', dict);
}
});
}
export { initialize };