How to implement a store in ember.js service

I tried to insert the repository from the initializer without success, so I use lookup for init in my service, but I don’t like it very much, I would rather keep things separate and insert injections into the initializer ..

Amber: 1.11.1

Ember data: 1.0.0-beta.16.1

jQuery: 1.11.2

DOES NOT WORK: Initializer

//app/initializers/initializer-store.js export default { name: 'initializer-store', after: 'store', initialize: function(container, application) { application.inject('service:mtg-level-service', 'store', 'store:main'); } }; 

WORKING: Service

 //app/services/mtg-level-service.js import Ember from 'ember'; export default Ember.Service.extend({ availableIn: ['controllers', 'routes'], store: null, init: function() { this._super(); this.set('store', this.container.lookup("store:main")); } }); 
+6
source share
1 answer

As of Ember v1.10:

 import Ember from 'ember'; export default Ember.Service.extend({ store: Ember.inject.service('store') }); 
+11
source

Source: https://habr.com/ru/post/986006/


All Articles