ember.js - Is there anyway to call on a service that has dependencies on other services within an initializer in Ember v1.11? -


i don't know if possible or not, within initializer need able call on userpreferences service fetch user's saved locale before performing fetch localized .json file. unfortunately, have preference service method called, unable call method within api service contained within it.

is there better way of doing this?

// initializer import ember 'ember';  export function initialize(container, application) {    // need obtain user prefereces existing service   var userprefs = container.resolver('service:user-preferences');   var prefs = new userprefs();    prefs.fetch().then(function () {     console.log('fetch done!!');   });    // fetch locale .json file here }  // userpreferences service import ember 'ember';  export default ember.service.extend({    session: ember.inject.service(),   api: ember.inject.service(),    _cachedprefs: null,    fetch: function () {     var self = this;      // error: unable api reference here     // => assertion failed: attempting lookup injected property on object without container, ensure object instantiated via container.     var api = this.get('api');     var userid = this.get('session.user.id');     var cachedprefs = this.get('_cachedprefs');      // ...   } } 

initializers can "pause" ember initialization this:

export function initialize(container, application) {    // need obtain user prefereces existing service   var userprefs = container.resolver('service:user-preferences');   var prefs = new userprefs();    application.deferreadiness();    prefs.fetch().then(function () {     application.advancereadiness();     console.log('fetch done!!');   });    // fetch locale .json file here } 

just remember match deferreadiness , advancereadiness pairs or cause deadlock.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -