-
-
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
[BUGFIX stable] Instance initializers should run before App.ready
#11289
[BUGFIX stable] Instance initializers should run before App.ready
#11289
Conversation
The original complaint is that routing begins before instance initializers are run, which means that some routes instances are created *before* the instance initializers are run, which means that you cannot reliably setup injections for routes in instance initializers, which are important for e.g. `store:main`. Since `App.ready` is guaranteed to run before routing begins, this effectively guarantees that instance initializers are run before routing begins. Fixes emberjs#11172
Called when the Application has become ready. | ||
The call will be delayed until the DOM has become ready. | ||
Called when the Application has become ready, immediately before routing | ||
begins. The call will be delayed until the DOM has become ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See line 186 ⬆️
Thanks for tackling this! Can you add a test that uses |
I was hoping no one would notice ;)
Clearly,
The But anyway, If you are using the ember.js/packages/ember-application/lib/system/application.js Lines 821 to 822 in a0acc6e
So I think I'll (or someone else 😉) need to do a lot more cleanup for I have other complains/fixes/suggestions for |
I have come to similar conclusions regarding the manual boot capability and fastboot, I mostly asked for the test because it seems currently broken and I want to make sure that the fix here (for the However, ember-application-visit is a flagged feature and we should definitely ensure that golden path works properly, so 👍 on this for now. We really need to get the |
…before-ready [BUGFIX stable] Instance initializers should run before `App.ready`
Just to be clear, #11172 does not affect If I am wrong then we should probably add the test even temporarily 😁 |
@chancancode - You are not wrong. My concern was that this changes the way an app boots (and definitely fixes #11172), which does in some way affect |
👍 |
@rwjblue Can this be cherry-picked as a (I'm lurking, so not sure but this sounded like a regression, not a new feature that was buggy. Please correct me if I'm wrong) |
I agree with @jayphelps, releasing |
@jayphelps - It was already cherry picked into release branch when you commented 💃, 1.12.1 will be released as soon as we get the Also, |
Not sure where a good place to drop this is, but seeing @chancancode imply that he MIGHT do some cleanup work around the boot process made we want to add some thoughts. These ideas are not RFC ready, but I feel like there should be a public API for booting Ember applications that includes;
I know the autoboot: true/false is just the first crack at getting FastBoot working, but long term it seems like something more flexible would be nice. For instance, in ember-islands I had a feature request that needed an Ember app booted without the router. I put in a horrible hack, and would love something better there. At a high level here are some situations I'm thinking about. Obviously this is all pseudocode, and needs some in-depth spelunking and more thought. // I wanted this for my addon
bootstrapRegistry();
runInitializers();
// startRouting(); no routing please
startEventDispatcher();
// I think FastBoot wants this
bootstrapRegistry();
runInitializers();
startRouting();
// startEventDispatcher(); no events needed
// An integrated component test might want
bootstrapRegistry();
// app.runInitializers(); no initializers please
// app.startRouting(); no routing needed
app.startEventDispatcher(); |
@mitchlloyd I added it to here! #11291 (comment) |
The original complaint is that routing begins before instance initializers are run, which means that some routes instances are created before the instance initializers are run, which means that you cannot reliably setup injections for routes in instance initializers, which are important for e.g.
store:main
.Since
App.ready
is guaranteed to run before routing begins, this effectively guarantees that instance initializers are run before routing begins.Fixes #11172