-
Notifications
You must be signed in to change notification settings - Fork 26.2k
APP_ROOT_SCOPE token #22185
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
APP_ROOT_SCOPE token #22185
Conversation
b39c35e
to
8287550
Compare
You can preview 8287550 at https://pr22185-8287550.ngbuilds.io/. |
// APP_ROOT_SCOPE is cast as a Type to allow for its usage as the scope parameter of @Injectable(). | ||
|
||
/** | ||
* A scope which targets the root injector. |
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 will be part of public API and needs a richer documentation with an example.
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.
Documented.
packages/core/src/di/scope.ts
Outdated
* | ||
* @experimental | ||
*/ | ||
export const APP_ROOT_SCOPE: Type<any> = new InjectionToken<boolean>( |
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.
8287550
to
eb6fa00
Compare
You can preview eb6fa00 at https://pr22185-eb6fa00.ngbuilds.io/. |
eb6fa00
to
fbaf7ad
Compare
You can preview fbaf7ad at https://pr22185-fbaf7ad.ngbuilds.io/. |
@Injectable() supports a scope parameter which specifies the target module. However, it's still difficult to specify that a particular service belongs in the root injector. A developer attempting to ensure that must either also provide a module intended for placement in the root injector or target a module known to already be in the root injector (e.g. BrowserModule). Both of these strategies are cumbersome and brittle. Instead, this commit adds a token APP_ROOT_SCOPE which provides a straightforward way of targeting the root injector directly, without requiring special knowledge of modules within it.
fbaf7ad
to
f57afca
Compare
You can preview f57afca at https://pr22185-f57afca.ngbuilds.io/. |
…lar#22185) @Injectable() supports a scope parameter which specifies the target module. However, it's still difficult to specify that a particular service belongs in the root injector. A developer attempting to ensure that must either also provide a module intended for placement in the root injector or target a module known to already be in the root injector (e.g. BrowserModule). Both of these strategies are cumbersome and brittle. Instead, this commit adds a token APP_ROOT_SCOPE which provides a straightforward way of targeting the root injector directly, without requiring special knowledge of modules within it. PR Close angular#22185
…lar#22185) @Injectable() supports a scope parameter which specifies the target module. However, it's still difficult to specify that a particular service belongs in the root injector. A developer attempting to ensure that must either also provide a module intended for placement in the root injector or target a module known to already be in the root injector (e.g. BrowserModule). Both of these strategies are cumbersome and brittle. Instead, this commit adds a token APP_ROOT_SCOPE which provides a straightforward way of targeting the root injector directly, without requiring special knowledge of modules within it. PR Close angular#22185
…lar#22185) @Injectable() supports a scope parameter which specifies the target module. However, it's still difficult to specify that a particular service belongs in the root injector. A developer attempting to ensure that must either also provide a module intended for placement in the root injector or target a module known to already be in the root injector (e.g. BrowserModule). Both of these strategies are cumbersome and brittle. Instead, this commit adds a token APP_ROOT_SCOPE which provides a straightforward way of targeting the root injector directly, without requiring special knowledge of modules within it. PR Close angular#22185
@alxhub I don't find APP_ROOT_SCOPE in the public API of core. Is this intended in favor of |
@SebastianM This has been redesigned: #22655 |
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. |
No description provided.