本文介绍了修复初始化程序在Ember 1.12.0中弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指的是在Ember 1.12中引入的特殊弃用。

我看了指南,但我不知道如何解决这个问题。



这里是我现在的代码片段

  initialize = 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。 provision.url +'/ v1 / configurations'
dataType:'json'
headers:
'Authorization':auth.get'token'
' 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

问题是,为了初始化我的 config 初始化器,我需要 auth-manager 我的其他初始化器大多需要 config auth-manager 初始化器来获得access_token和连接端点。 p>

在ember-cli项目中,应该有一个文件用于实例初始化程序,一个用于初始化程序的注册。



解决方案

我没有打过这个,但希望这个会导致某处有用。


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

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.

解决方案

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

这篇关于修复初始化程序在Ember 1.12.0中弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 19:41