Is it possible to inject the ApplicationAdapter?


#1

I am rather new to ember, but I am trying to setup my app to use a single configuration singleton service that can be re-used by not only the DS.RESTAdapter, but some other parts of my app (mostly components).

As an aside, I noticed that Ember.Application.initializer shows up as a section in the docs, but there’s no API reference?

Thanks for any help!

Here’s a jsbin of what I am attempting to do


#2

You sure can and you were almost there. http://jsfiddle.net/7ZWZg/8/


#3

@jasonmit Excellent! Thank you very much!

Do you know if there’s a good resource discussing the container, and when to do things to it vs. app.register or app.inject? Also is there a reference to which Ember ‘types’ correspond with strings? I find this somewhat confusing.

Thanks again!


#4

app.register just ends up calling the container.register

      function () {
        var container = this.__container__;
        container.register.apply(container, arguments);
      } 

and similarly, app.inject calls container.injection

      function () {
        var container = this.__container__;
        container.injection.apply(container, arguments);
      } 

So use whichever you prefer :smile:

Resources:

http://balinterdi.com/2014/05/01/dependency-injection-in-ember-dot-js.html