Javascript

Using Services in Services in Ember

Mar 29, 2016
Javascript, Ember

Ember now has the concept of services which are incredible useful and the documentation for how to use them is good. What, however, is not so well covered is how to include a service within a service. In my previous blog post Building an Ember Message Bus I showed how to create an event bus service and inject it into routes, controllers, components and models. However, I soon discovered that the particular work application I was working on I need to be able to access the event bus service from within one of my other services. ...

Building an Ember Message Bus

Mar 29, 2016
Javascript, Ember

When I was looking for an event bus for the Ember application I was writing for work I came across Paul Cowan’s blog article called Emberjs - Simple Global Event Bus. This event bus uses the built in Ember.Evented and at it’s core looks as follows: App.EventBus = Ember.Service.extend(Ember.Evented, { publish: function() { return this.trigger.apply(this, arguments); }, subscribe: function() { return this.on.apply(this, arguments); }, unsubscribe: function() { return this.off.apply(this, arguments); } }); I’m using ember-cli 2. ...