We have a view helper class that shows online or offline status. This is based on a singleton object that lets the view know if a given user is online or offline. Instead of creating a global singleton, I was hoping to use the DI container in Ember.
// assume app-wide scope
App.inject(thingToInjectOn, property, thingToInject);
App.register(thingToInject, factory);
App.register('store:main', Store);
// example form ED. Injection on all contorllers
App.inject('controller', 'store', 'store:main');
// injection on a specific controller
App.inject('controller:person', 'facebook', 'service:facebook');
This works. I would like to do the same with views
While the container works great with injection of dependent objects for routes and controller, I was unable to inject a dependent object in the view. I would like some input on what is the right approach here and if it is ok to inject objects into views ?
Thoughts ? I think it would be cool to have some guide/docs on how to cleanly use the container and if there is a better way to lookup an object from container instead of using __container__