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

Expand doc for APP_INITIALIZER token #34760

Closed
wants to merge 2 commits into from

Conversation

@jbogarthyde
Copy link
Contributor

jbogarthyde commented Jan 13, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

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?

  • Yes
  • No
Copy link
Contributor

AndrewKushnir left a comment

👍 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.

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 13, 2020

@@ -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

This comment has been minimized.

Copy link
@CaerusKaru

CaerusKaru Jan 14, 2020

Member

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

This comment has been minimized.

Copy link
@CaerusKaru

CaerusKaru Jan 14, 2020

Member

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.

This comment has been minimized.

Copy link
@jbogarthyde

jbogarthyde Jan 14, 2020

Author Contributor

Thank you!

@jbogarthyde jbogarthyde force-pushed the jbogarthyde:jb-apidoc-init branch from e738e32 to 75831e2 Jan 14, 2020
@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 14, 2020

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 14, 2020

@jbogarthyde jbogarthyde moved this from Waiting for Approval to Waiting for Merge in docs Jan 14, 2020
atscott added a commit that referenced this pull request Jan 14, 2020
@atscott atscott closed this in 23cbfa7 Jan 14, 2020
@jbogarthyde jbogarthyde deleted the jbogarthyde:jb-apidoc-init branch Jan 15, 2020
@jbogarthyde jbogarthyde moved this from Waiting for Merge to Done in docs Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.