Fix obsolete initializers in Ember 1.12.0

I mean this particular condemnation, which was introduced in Ember 1.12

lookup was called in the registry. The initializer API no longer works receives the container, and you should use instanceInitializer to search for objects from the container

I looked at the guide, but I'm not sure how to fix it.

Here is the code snippet that I have at the moment

 initialize = (container, app) -> auth = container.lookup('auth-manager:main') local_config = ($.ajax type: 'GET' url: '/config.json' async:false ).responseJSON external_config = ($.ajax type: 'GET' url: local_config.crm.provisioning.url + '/v1/configurations' dataType: 'json' headers: 'Authorization': auth.get 'token' 'Accept': 'application/json' 'Content-Type': 'application/json' async: false error: (e)-> if e.status == 401 window.location.href = window.location.origin + '/auth.html?src_url=' + window.location.href ).responseJSON ConfigInitializer = name: 'config' after: 'auth-manager' initialize: initialize 

The problem is that initializing the config initializer requires the auth-manager initializer. Most other initializers require config and auth-manager initializers to obtain access endpoints and connection endpoints.

In the ember-cli project, should there be one file for the instance initializer and one for registering the initializer?

The example given in the ember doc really confuses me.

+6
source share
1 answer

I haven't hit this yet, but hopefully it will be somewhere useful. https://github.com/emberjs/ember.js/issues/10177

+1
source

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


All Articles