-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Route view is initialized when model changes #4353
Comments
/cc @ef4 ... this seems related to the optimization to not re-render between route transitions if only the models (and not the route hierarchy) has changed. |
Yes, it's intentional that a new View object gets instantiated. See the code changes in #2593. The reason for this is that the view gets to pick what template and context it wants to render with, so we can't tell if the template and context are unchanged until after instantiating the view. The only way to avoid creating this "unused" view object would be to change the view API so that views can no longer dynamically override those things, which is probably not worth it. |
Thanks @ef4. Seems intentional and not likely to change any time soon, so closing. |
I think we should strongly consider if we can take another approach that prevents this view from needing to be instantiated, while preserving @ef4's optimization. |
Seems to be a common theme :) walking the prototype, anyone? |
no, i think there exists a path were we defer actual creation of views till much much later, merely passing the view factory around till the very last moment. This will likely sort out, or enable sorting out several other quirks |
Hmm ok. I'm still learning the ember code base, and I'm trying to wrap my head around changing a view's template / context on a model change. Is there a specific use case or an example jsbin or something that can help me get a better idea of how / why you'd do that? If I was doing something like that, I would expect to have to override renderTemplate in the route. If enforcing that is an acceptable solution, then the equality check of the views could be moved up into the route's render method. |
@stefanpenner what's the next step on this? |
See #5264 |
I've noticed that a route's view is initialized every time the model changes on a route, even though the model is actually rendered into the original view.
Here's a quick jsbin:
http://jsbin.com/ucanam/3732/edit
Is there any reason for the view to be created (and then not used)? Or should I try and find where in the router this is happening?
The text was updated successfully, but these errors were encountered: