Share Services with Dependency Injection
The features we’ve covered so far help you implement a sound design by creating reusable classes and sharing them across objects. Mixins and utilities are great for abstracting behavior, but for more complex abstractions, you’ll want to create a service and use dependency injection to sprinkle it throughout your app.
“Service” can be interpreted to mean different things, so let’s start by defining what we mean by a service. A service is a self-contained unit of functionality. It provides unrelated objects access to its functionality in a loosely coupled way. Ember relies on a few services out of the box. For instance, the application’s instance of Ember.Router is a good example of a service: it manages ...
Get Deliver Audacious Web Apps with Ember 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.