-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
fix(ivy): ensure that LOCALE_ID
is set after app initializers
#34830
fix(ivy): ensure that LOCALE_ID
is set after app initializers
#34830
Conversation
packages/core/src/application_ref.ts
Outdated
@@ -315,6 +310,12 @@ export class PlatformRef { | |||
const initStatus: ApplicationInitStatus = moduleRef.injector.get(ApplicationInitStatus); | |||
initStatus.runInitializers(); | |||
return initStatus.donePromise.then(() => { | |||
// If the `LOCALE_ID` provider is defined at bootstrap we set the value for runtime i18n | |||
// (ivy) |
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.
This (ivy)
bit seems highly redundant considering how close it is to the next condition
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.
Fair point :-)
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.
LGTM 👍 Thanks for the fix Pete!
Before ivy it was possible to configure a mutable service value in an application initializer (by providing an `APP_INITIALIZER`) that could be read in the provider of `LOCALE_ID`. This is a common scenario if you wanted to load the locale id asynchronously from an HTTP request for instance. When using the ivy, the runtime needs to be told what the current locale is, which is done by calling the `setLocaleId()` function with the value injected by the `LOCALE_ID` token. Previously this was being done before the application initializers were run, which meant that the `LOCALE_ID` provider was being executed before the app initializers had a chance to get a new value for it. Now this initalization of the locale for the ivy runtime is done after the application initializers have been run. Closes angular#34701
d96581d
to
a6b86b7
Compare
@AndrewKushnir - I updated the comment per the suggestion by @alfaproject above. This should not affect the presubmit. |
Before ivy it was possible to configure a mutable service value in an application initializer (by providing an `APP_INITIALIZER`) that could be read in the provider of `LOCALE_ID`. This is a common scenario if you wanted to load the locale id asynchronously from an HTTP request for instance. When using the ivy, the runtime needs to be told what the current locale is, which is done by calling the `setLocaleId()` function with the value injected by the `LOCALE_ID` token. Previously this was being done before the application initializers were run, which meant that the `LOCALE_ID` provider was being executed before the app initializers had a chance to get a new value for it. Now this initalization of the locale for the ivy runtime is done after the application initializers have been run. Closes #34701 PR Close #34830
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Before ivy it was possible to configure a mutable service value
in an application initializer (by providing an
APP_INITIALIZER
)that could be read in the provider of
LOCALE_ID
. This is a commonscenario if you wanted to load the locale id asynchronously from
an HTTP request for instance.
When using the ivy, the runtime needs to be told what the current
locale is, which is done by calling the
setLocaleId()
function withthe value injected by the
LOCALE_ID
token. Previously this wasbeing done before the application initializers were run, which meant
that the
LOCALE_ID
provider was being executed before theapp initializers had a chance to get a new value for it.
Now this initalization of the locale for the ivy runtime is done after the
application initializers have been run.
Closes #34701