You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 16, 2022. It is now read-only.
As part of the runApp migration, I ran into the following issues:
You could never override services in bootstrapFactory (missing feature)
To be able to override services, I add to add a hacky "middle" injector (internal):
/// **INTERNAL ONLY**: Creates a new application-level Injector.////// This is more complicated than just creating a new Injector, because we want/// to make sure we allow [userProvidedInjector] to override _some_ top-level/// services (`APP_ID`, `ExceptionHandler`) _and_ to ensure that Angular-level/// services (`ApplicationRef`) get the user-provided versions.Injector_appInjector(InjectorFactory userProvidedInjector) {
// These are the required root services.final minimalInjector =minimalApp(platformInjector());
// These are the user-provided overrides.final userInjector =userProvidedInjector(minimalInjector);
// Get a handle of NgZone, so we can create ApplicationRef in it.finalNgZone ngZone =unsafeCast(minimalInjector.get(NgZone));
// ... and then we add ApplicationRef, which has the unique property of// injecting services (specifically, `ExceptionHandler` and `APP_ID`) that// might have come from the user-provided injector, instead of the minimal.//// We also add other top-level services with similar constraints:// * `AppViewUtils`return ngZone.run(() {
returnnewInjector.map({
ApplicationRef:newApplicationRefImpl(
unsafeCast(minimalInjector.get(PlatformRef)),
ngZone,
userInjector,
),
AppViewUtils:newAppViewUtils(
unsafeCast(userInjector.get(APP_ID)),
unsafeCast(minimalInjector.get(SanitizationService)),
unsafeCast(minimalInjector.get(EventManager)),
),
}, userInjector);
});
}
... which led me to the following:
We should document what root-level services are provided by AngularDart
We should document what can be overridden and what cannot
AFAIK, only ExceptionHandler and APP_ID are really safe for overriding
We should consider removing the root-level injector entirely, making DI pseudo optional
The reason I say pseudo optional is that likely we will still need to provide some services, likely through an Injector.map, like above, so others can inject them in DI, but we don't need to use DI ourselves in order to create the root-level services.
The text was updated successfully, but these errors were encountered:
... now with `Testability` working again, and other bug fixes.
Work towards #914.
Closes#1048Closes#1174.
Filed #1175.
Filed #1179.
PiperOrigin-RevId: 191628083
... now with `Testability` working again, and other bug fixes.
Work towards #914.
Closes#1048Closes#1174.
Filed #1175.
Filed #1179.
PiperOrigin-RevId: 191628083
... now with `Testability` working again, and other bug fixes.
Work towards #914.
Closes#1048Closes#1174.
Filed #1175.
Filed #1179.
PiperOrigin-RevId: 191628083
michilu
pushed a commit
to michilu/scaffold
that referenced
this issue
Apr 13, 2018
As part of the
runApp
migration, I ran into the following issues:bootstrapFactory
(missing feature)... which led me to the following:
ExceptionHandler
andAPP_ID
are really safe for overridingThe reason I say pseudo optional is that likely we will still need to provide some services, likely through an
Injector.map
, like above, so others can inject them in DI, but we don't need to use DI ourselves in order to create the root-level services.The text was updated successfully, but these errors were encountered: