Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixing Initializers deprecation in Ember 1.12.0

I am refering to this particular deprecation that was introduced in Ember 1.12

lookup was called on a Registry. The initializer API no longer receives a container, and you should use an instanceInitializer to look up objects from the container

I looked at the guide, but I am unsure on how to fix this.

Here's a snippet of the code 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 I require the auth-manager initializer in order to initialize my config initializer. Most of my other initializers require both the config and auth-manager initializers to get an access_token and connection endpoints.

In a ember-cli project should there be one file for the instance initializer and one for the registration of the initializer ?

The example given in the ember doc really confuses me.

like image 930
QuantumLicht Avatar asked May 28 '15 13:05

QuantumLicht


1 Answers

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

like image 112
redOctober13 Avatar answered Oct 19 '22 21:10

redOctober13