Conversation
424d469 to
ba03f2f
Compare
ca6934c to
ab2815d
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
Looks great 👍 Just left a few minor comments (none of them are blockers, we can update things in followup PRs).
packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.ts
Outdated
Show resolved
Hide resolved
packages/core/src/di/r3_injector.ts
Outdated
There was a problem hiding this comment.
| * created by the framework. | |
| */ | |
| * created by the framework. | |
| * | |
| * @publicApi | |
| */ |
atscott
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
atscott
left a comment
There was a problem hiding this comment.
reviewed-for: size-tracking
dylhunn
left a comment
There was a problem hiding this comment.
reviewed-for: public-api, size-tracking
packages/core/src/di/r3_injector.ts
Outdated
There was a problem hiding this comment.
Here's another instance of env. Is there any way to make these not magic strings?
There was a problem hiding this comment.
They're sort of by definition magic strings, since they're typically generated by the compiler.
jessicajaniuk
left a comment
There was a problem hiding this comment.
reviewed-for: public-api, size-tracking
Previously there was a test ordering issue with the application_module_spec tests where the value of `getLocaleId()` depended on the order in which tests ran. Specifically, `setLocaleId()` lower-cases the current locale ID, so the measured value in a test depended on whether a previous test had called `setLocaleId()` (the difference between 'en-US' and 'en-us').
9d8065d to
dcae004
Compare
e173bf1 to
c72330f
Compare
This commit implements the `importProvidersFrom` function that allows extracting a list of `Provider`s from a list of NgModule types. The R3Injector which implements DI at the "module" level for Angular is refactored to use this functionality under the hood. This commit also implements `INJECTOR_INITIALIZER`, a DI multi-provider token which is used to run initialization logic when an injector is created.
packages/core/src/render3/index.ts
Outdated
There was a problem hiding this comment.
nit: import without usage?
There was a problem hiding this comment.
OMG, tired brain :-)
This commit exposes a new `EnvironmentInjector` abstraction, which generalizes the "module injector" concept to injectors that are not based on NgModules. An EnvironmentInjector is a conceptual analogue of an `NgModuleRef` - it represents an injector on the former "module" DI hierarchy in Angular (now renamed to the "environment injector hierarchy"). Environment injectors are created via the `createEnvironmentInjector` function from a list of `Provider`s. For backwards compatibility with current code using `NgModuleRef`, `EnvironmentInjector`s are wrapped by an adapter `NgModuleRef` implementation, so injecting `NgModuleRef` always returns the latest `EnvironmentInjector`, even if that injector was not based on an NgModule. Conversely, NgModule-based `NgModuleRef`s created via `createNgModuleRef` are _also_ `EnvironmentInjector`s.
This commit adds a new internal scope to `R3Injector` for `EnvironmentInjector`s specifically. This will allow us to scope services to the environment side of the injector hierarchy specifically, as opposed to the `'any'` scope which also includes view-side injectors created via `Injector.create`. For now, this functionality is not exposed publicly, but is available to use within `@angular/core` only.
atscott
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
|
Caretaker: this has all required approvals |
|
This PR was merged into the repository by commit 3578e94. |
This commit implements the `importProvidersFrom` function that allows extracting a list of `Provider`s from a list of NgModule types. The R3Injector which implements DI at the "module" level for Angular is refactored to use this functionality under the hood. This commit also implements `INJECTOR_INITIALIZER`, a DI multi-provider token which is used to run initialization logic when an injector is created. PR Close #45626
…#45626) This commit exposes a new `EnvironmentInjector` abstraction, which generalizes the "module injector" concept to injectors that are not based on NgModules. An EnvironmentInjector is a conceptual analogue of an `NgModuleRef` - it represents an injector on the former "module" DI hierarchy in Angular (now renamed to the "environment injector hierarchy"). Environment injectors are created via the `createEnvironmentInjector` function from a list of `Provider`s. For backwards compatibility with current code using `NgModuleRef`, `EnvironmentInjector`s are wrapped by an adapter `NgModuleRef` implementation, so injecting `NgModuleRef` always returns the latest `EnvironmentInjector`, even if that injector was not based on an NgModule. Conversely, NgModule-based `NgModuleRef`s created via `createNgModuleRef` are _also_ `EnvironmentInjector`s. PR Close #45626
This commit adds a new internal scope to `R3Injector` for `EnvironmentInjector`s specifically. This will allow us to scope services to the environment side of the injector hierarchy specifically, as opposed to the `'any'` scope which also includes view-side injectors created via `Injector.create`. For now, this functionality is not exposed publicly, but is available to use within `@angular/core` only. PR Close #45626
|
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. |
This PR includes a couple commits which introduce the new
EnvInjectorconcept.EnvInjectoris a generalized version ofNgModuleRefwhich represents the "module injector" (now renamed to "environment injector"). It's one of the primitives needed to support upcoming standalone components APIs.