Services: A Rumination on Introducing a New Role into the Ember Programming Model

It seems that the “job to be done” for a service is not clear here. It might be helpful to think about the ways a service differs from a controller (and what they have in common).

Jobs common to Service & Controller

  • global
  • singleton (?)
  • managed by the container
  • Manages (unpersisted) application state

Jobs for service only

  • ?

Jobs for controller only

  • ?

I am not super experienced with Ember so I’m sure others can come up with a more complete list but currently it seems that controllers and services are very similar.

This might be (read: probably is) a daft idea but perhaps we should consider a way of blessing access to certain controllers from other parts of the app e.g.

App.BlahController = Ember.ObjectController.extend({
  exposeAsServiceTo: ['routes', 'controllers'], // routes|controllers|models|all|none etc.
  // ...
});

and then elsewhere

Ember.Object.extend({
  inject: ['blahService', 'fooService'], // append 'Service' to be more explicit
  // ... 
});