I have a database manager singleton that I create with the following:
App.Mongo = Ember.Object.extend({...})
App.register("mongo:main", App.Mongo);
App.inject("route", "mongo", "mongo:main");
App.inject("controller", "mongo", "mongo:main");
Now inside that I want to use another singleton:
App.Factory = Ember.Object.extend({...})
App.register("factory:main", App.Factory);
App.inject("route", "factory", "factory:main");
App.inject("controller", "factory", "factory:main");
App.inject("object:mongo", "factory", "factory:main");
Is there a supported way to accomplish this yet?
I’d like to know the answer to this as well. I’ve got a factory I’d like to inject my socket and store singletons into. I thought it would be something as simple as:
Ember.Application.initializer({
name: "factory",
after: "socket",
initialize: function (container, application) {
container.register('factory:main', Ember.Factory);
application.inject('factory:main', 'store', 'store:main');
application.inject('factory:main', 'socket', 'socket:main');
}
});
Where Ember.Factory = Ember.Object.extend({})
;
However, calling Ember.Factory.create()
does not result in an object with store
and socket
properties.
My factory happens to be something that’s meant to be extended, much like DS.Model
. My App has App.FooFactory = Ember.Factory.extend();
. Instances of App.FooFactory also fail to have session and store properties.
I’ve tried several variations on what I register, what I inject upon, and when / how I create the FooFactory instance, but all fail to have store
or socket
injected.