feat: add a PLATFORM_ID token that provides a platform id Object. (#14647)
This commit is contained in:
@ -46,6 +46,12 @@ function _randomChar(): string {
|
||||
*/
|
||||
export const PLATFORM_INITIALIZER = new InjectionToken<Array<() => void>>('Platform Initializer');
|
||||
|
||||
/**
|
||||
* A token that indicates an opaque platform id.
|
||||
* @experimental
|
||||
*/
|
||||
export const PLATFORM_ID = new InjectionToken<Object>('Platform ID');
|
||||
|
||||
/**
|
||||
* All callbacks provided via this token will be called for every component that is bootstrapped.
|
||||
* Signature of the callback:
|
||||
|
@ -16,7 +16,7 @@ export * from './version';
|
||||
export * from './util';
|
||||
export * from './di';
|
||||
export {createPlatform, assertPlatform, destroyPlatform, getPlatform, PlatformRef, ApplicationRef, enableProdMode, isDevMode, createPlatformFactory, NgProbeToken} from './application_ref';
|
||||
export {APP_ID, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER, APP_BOOTSTRAP_LISTENER} from './application_tokens';
|
||||
export {APP_ID, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER, PLATFORM_ID, APP_BOOTSTRAP_LISTENER} from './application_tokens';
|
||||
export {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
|
||||
export * from './zone';
|
||||
export * from './render';
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import {PlatformRef, PlatformRef_, createPlatformFactory} from './application_ref';
|
||||
import {PLATFORM_ID} from './application_tokens';
|
||||
import {Console} from './console';
|
||||
import {Provider} from './di';
|
||||
import {Reflector, reflector} from './reflection/reflection';
|
||||
@ -18,6 +19,8 @@ function _reflector(): Reflector {
|
||||
}
|
||||
|
||||
const _CORE_PLATFORM_PROVIDERS: Provider[] = [
|
||||
// Set a default platform name for platforms that don't set it explicitly.
|
||||
{provide: PLATFORM_ID, useValue: 'unknown'},
|
||||
PlatformRef_,
|
||||
{provide: PlatformRef, useExisting: PlatformRef_},
|
||||
{provide: Reflector, useFactory: _reflector, deps: []},
|
||||
|
Reference in New Issue
Block a user