MCPcopy Create free account
hub / github.com/angular/angular / createPlatformFactory

Function createPlatformFactory

packages/core/src/platform/platform.ts:65–88  ·  view source on GitHub ↗
(
  parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null,
  name: string,
  providers: StaticProvider[] = [],
)

Source from the content-addressed store, hash-verified

63 * @publicApi
64 */
65export function createPlatformFactory(
66 parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null,
67 name: string,
68 providers: StaticProvider[] = [],
69): (extraProviders?: StaticProvider[]) => PlatformRef {
70 const desc = `Platform: ${name}`;
71 const marker = new InjectionToken(desc);
72 return (extraProviders: StaticProvider[] = []) => {
73 let platform = getPlatform();
74 if (!platform) {
75 const platformProviders: StaticProvider[] = [
76 ...providers,
77 ...extraProviders,
78 {provide: marker, useValue: true},
79 ];
80
81 platform =
82 parentPlatformFactory?.(platformProviders) ??
83 createPlatform(createPlatformInjector(platformProviders, desc));
84 }
85
86 return typeof ngServerMode !== 'undefined' && ngServerMode ? platform : assertPlatform(marker);
87 };
88}
89
90/**
91 * Helper function to create an instance of a platform injector (that maintains the 'platform'

Callers 8

bootstrap_spec.tsFile · 0.90
browser.tsFile · 0.90
browser.tsFile · 0.90
platformServerFunction · 0.90
server.tsFile · 0.90
testing.tsFile · 0.90

Calls 4

getPlatformFunction · 0.85
createPlatformFunction · 0.85
assertPlatformFunction · 0.85
createPlatformInjectorFunction · 0.70

Tested by

no test coverage detected