This document aims to help aggregate issues and solutions around the defaultContainer deprecation.
The Error Message:
Using the defaultContainer is no longer supported. [defaultContainer#lookup]
Well it is still there, and will continue to work for some time. Likely it will be gone by 1.0.0 final
We recieved several issues, these issues were non-obvious but it appeared that they where caused by the defaultContainer leaking between tests. This obviously lead to very unexpected test failures. The quick fix was obviously to ensure the defaultContainer was purged between tests. Upon further investigation, almost all the issues turned out to be childViews which were not wired up correctly. For example not using this.createChildView
on creation of childViews. Ultimately, the existence of the defaultContainer was masking the reported issues, and likely many more. In addition the obvious issues, we are trying to remove our dependency on globals (but that is another story).
if you are creating dynamic views in the context of the parentView, you should be using:
this.createChildView(viewClass, viewAttributes)
if you are creating views outside the context of a parentView (this may not be recommended, but it is happening) you will want to make sure to instantiate your view via the container itself.
this.container.lookup('view:apple')
// will provide a instance of apple view.
how container lookups are resolved
- appendTo another ember view, should then grab the container of that view.
- continue to flush out this gist
- improve docs/guides
- improve deprecation warnings
- explore methods where this works without developer thought (without perf regressions)
Post a comment, describing the issue, and hopefully a jsbin or jsfiddle demonstrating the issue. As time permits, a solution or migration path will finds its way up into this document.
A: App is the root, and as such it creates the initial container.
A: typically, it is using the container passed down the view hierarchy, and this typically occurs at creation.
A: likely, but its not just the container, it is a place for the framework to wire-up other things. https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/views/view.js#L2072
(ask questions in the comments and I will hoist them here.)
@pivotal-medici & @edimoldovan emberjs/ember.js#2821 should handle your scenarios.
@nightire by default the ApplicationView is correctly appended to the rootElement for you, container and all. This view will be setup correctly and all its children and descendants should also be setup for you. If you choose to append a view yourself, which is totally allowed, although not needed in many situations, you must setup the dependencies correctly yourself.
When appending a root view yourself, you will typically do this within the router, not from
Application#ready
. That being said, ember is flexible and allows you to solve the problem in many ways. Can you provide a more detail example so i can understand your intent?