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
Expand doc for APP_INITIALIZER token #34760
Conversation
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 update.
I think it'd be great to add an example in the followup PR on how this token can be used.
You can preview e738e32 at https://pr34760-e738e32.ngbuilds.io/. |
@@ -12,7 +12,13 @@ import {Inject, Injectable, InjectionToken, Optional} from './di'; | |||
|
|||
|
|||
/** | |||
* A function that will be executed when an application is initialized. | |||
* An injection token that allows you to inject one or more functions to be executed during |
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.
I think we should say provide one or more functions to be executed
. Those functions then get injected at application startup and run. This verbiage is similar to how the value is actually used in code:
{
provide: APP_INITIALIZER,
useValue: () => {}
}
* app initialization. If any of these functions returns a Promise, initialization | ||
* does not complete until the Promise is resolved. | ||
* | ||
* You can, for example, create a factory function that loads an external configuration |
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 whole example has me a little confused, mostly I think just by the wording. If I get your intention correctly, maybe this would be more direct?
You can, for example, create a factory function that loads language data or an external configuration, and provide that function to the APP_INITIALIZER token.
That way, the function is executed during the application bootstrap process, and the needed data is available on startup.
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.
Thank you!
e738e32
to
75831e2
Compare
You can preview 75831e2 at https://pr34760-75831e2.ngbuilds.io/. |
You can preview 5a7de1a at https://pr34760-5a7de1a.ngbuilds.io/. |
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The description of https://angular.io/api/core/APP_INITIALIZER is brief and uninformative.
Issue Number: #34703
What is the new behavior?
Expands the API doc description.
Needs an example or pointer to additional doc to be really useful.
The subject does not appear to be covered anywhere in the current doc, but lots of external discussion.
Does this PR introduce a breaking change?