angular
angular copied to clipboard
Add application-level startup settings
I'd like to propose having something like the following class available:
import 'package:meta/meta.dart';
@sealed
class AppOverrides {
final bool enableTestability;
const AppOverrides({
this.enableTestability = true,
});
}
... as a start. The runApp
and runAppAsync
functions would support it:
ComponentRef<T> runApp<T>(
ComponentFactory<T> componentFactory, {
InjectorFactory createInjector,
AppOverrides overrides,
}) {
// ...
}
So, for example, you could do the following:
void main() {
runApp(
app.AppComponentNgFactory,
createInjector: hackerNewsApp,
overrides: AppOverrides(
enableTestability = false,
),
);
}
... in order to disable Testability
, and functionality in NgZone
present only for it. This would drop the minimum amount of code-size, as well as remove a very small performance overhead currently for any registered timers within NgZone
.
The class and field would also exist so we could add more "advanced" options/overrides in the future, including potentially using it to set a custom Sanitizer, completely disable NgZone
, and more.
One idea: Start with everything optimized instead of opting-out of deopts.
I like this idea overall, but I'm not sure its compatible with the original purpose of #887 . The signature for runApp/runAppAsync is not suitable for an application that does not have a root component.