【发布时间】:2015-08-11 01:36:23
【问题描述】:
我指的是在 Ember 1.12 中引入的这种特殊的弃用
lookup在注册表中被调用。initializerAPI 不再 收到一个容器,你应该使用instanceInitializer从容器中查找对象
我查看了指南,但不确定如何解决此问题。
这是我目前拥有的代码的 sn-p
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
问题是我需要auth-manager 初始化程序才能初始化我的config 初始化程序。我的大多数其他初始化程序都需要 config 和 auth-manager 初始化程序来获取 access_token 和连接端点。
在 ember-cli 项目中是否应该有一个文件用于实例初始化程序,一个文件用于初始化程序的注册?
ember 文档中给出的例子真的让我很困惑。
【问题讨论】:
-
我相信这个信息会在未来的版本中出现。我注意到昨天在 github 上的一个关于文档和生成器逻辑的对话。在烟雾散去之前,我只是忽略了初始化警告——尤其是因为 ember-data 仍在将它们扔掉。
-
@adammokan,能否请您添加此对话的链接?谢谢!
标签: ember.js coffeescript ember-cli