Skip to content
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

Controller's init method is called before model method of application route #15495

Closed
mani-mishra opened this issue Jul 12, 2017 · 5 comments
Closed
Labels

Comments

@mani-mishra
Copy link
Contributor

mani-mishra commented Jul 12, 2017

Issue on Ember 2.14

So our app is breaking on upgrading to 2.14, as the init method of controller for a particular route is executed before the model method of application route.

We have bunch of features/flags check in init methods, and all those are being set in application model.

This is working as expected (model => afterModel => init of controller of the route being loaded) till ember 2.13.3

@mani-mishra mani-mishra changed the title Controller init is called before model method of application route - ember 2.14 Controller's init method is called before model method of application route Jul 12, 2017
@mani-mishra
Copy link
Contributor Author

mani-mishra commented Jul 12, 2017

As ember twiddle doesn't support newer versions of ember, created a demo app. Below are the screenshots and links for the same.

For 2.13.3: https://github.com/mani-mishra/ember-15495-demo/tree/2.13.3

2 13

For 2.14.0: https://github.com/mani-mishra/ember-15495-demo/tree/2.14.0
2 14 0

@rwjblue
Copy link
Member

rwjblue commented Jul 14, 2017

I am not 100% sure without more details or a reproduction, but I believe that this is due to the change I made in #15178 (I tried to ensure that PR description explains the rationale for the change). In general, there has never been a guarantee that controllers would be created in any specific order related to the route structure.

That PR was definitely fixing a number of bugs and edge cases with the prior behaviors, but its also one of those situations where a good fix happened to accidentally break a subtle behavior your app was relying on and I apologize for that.

Sadly, I believe that you will need to refactor your logic in this case.

@Serabe Serabe added the wontfix label Jul 15, 2017
@Serabe
Copy link
Member

Serabe commented Jul 15, 2017

As commented before and in the PR text, this won't be fixed for the reasons there specified. I am afraid this is one of the rare cases where we cannot fix all the edge cases. We can offer some support through Slack to help through this refactor. If you are not there yet, you can use the Slackin app to sign in.

Thank you and we are sorry.

@Serabe Serabe closed this as completed Jul 15, 2017
@mani-mishra
Copy link
Contributor Author

Thanks @rwjblue and @Serabe for the explanation. Appreciate it. 👍

@mani-mishra
Copy link
Contributor Author

@rwjblue and @Serabe, for fixing the above I was doing the same changes in our app and the potential fix is following the below assumption.

Application's route model hook will finish before any individual route's lifecycle(except init) hook is run.
Example: application route model => route A's beforeModel => route A's activate => route A's model

I didn't find any documentation for such, so please correct me if the above assumption is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants