feat(bootstrap): add platform and app initializers
Often some init logic needs to run when a platform or an application is boostrapped. For example, boostraping a platform requires initializing the dom adapter. Now, it can be done as follows: new Provider(PLATFORM_INITIALIZER, {useValue: initDomAdapter, multi: true}), All platform initializers will be run after the platform injector has been created. Similarly, all application initializers will be run after the app injector has been created. Closes #5355
This commit is contained in:
@ -48,3 +48,14 @@ export const APP_ID_RANDOM_PROVIDER: Provider =
|
||||
function _randomChar(): string {
|
||||
return StringWrapper.fromCharCode(97 + Math.floor(Math.random() * 25));
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that will be executed when a platform is initialized.
|
||||
*/
|
||||
export const PLATFORM_INITIALIZER: OpaqueToken =
|
||||
CONST_EXPR(new OpaqueToken("Platform Initializer"));
|
||||
|
||||
/**
|
||||
* A function that will be executed when an application is initialized.
|
||||
*/
|
||||
export const APP_INITIALIZER: OpaqueToken = CONST_EXPR(new OpaqueToken("Application Initializer"));
|
Reference in New Issue
Block a user