After updating my app to Ember 1.12.0, I notice lots of warnings like this:
lookup
was called on a Registry. Theinitializer
API no longer receives a container, and you should use aninstanceInitializer
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With