17

After updating my app to Ember 1.12.0, I notice lots of warnings like this:

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. See http://emberjs.com/guides/deprecations#toc_deprecate-access-to-instances-in-initializers for more details.

This seems to be caused by using container.lookup from an initializer, which was fine in older versions of Ember.

From the blog post about Ember 1.12.0, it seems like in a Global-based Ember application, the difference between making an Initializer and an Instance Initializer is using

App.initializer({
    ...
});

vs

App.instanceInitializer({
    ...
});

However, it doesn't seem to describe how to use instance initializers with the Ember CLI. Does anyone know how to use them?

EDIT: Turns out a browser plugin of all things was blocking the information I needed on the original blog post. I'll leave this here in case it's useful to anyone, but in the CLI regular initializers go inside

app/initializers/__my__initializer.js

while Instance Initializers are defined like

app/instance-initializers/__my__initializer.js

EDIT 2: If anyone is coming here because they're experiencing the same problem, this issue on the Ember.js repo references this problem and includes a link to a jsfiddle demonstrating the problem.

Alex LaFroscia
  • 961
  • 1
  • 8
  • 24
  • thanks buddy, i did think it was obvious to use app/instance-initializers/__my__initializer.js once you follow the naming convention of ember-cli. it was good to get it confirmed! Btw the stack community is strict on providing answers as question. The edit part that you have mentioned, kindly add it as an anwer. – wallop May 21 '15 at 17:22

1 Answers1

7

Turns out a browser plugin of all things was blocking the information I needed on the original blog post. I'll leave this here in case it's useful to anyone, but in the CLI regular initializers go inside

app/initializers/__my__initializer.js

while Instance Initializers are defined like

app/instance-initializers/__my__initializer.js
Alex LaFroscia
  • 961
  • 1
  • 8
  • 24