MCPcopy
hub / github.com/angular/angular / createPlatformFactory

Function createPlatformFactory

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

Source from the content-addressed store, hash-verified

70 * @publicApi
71 */
72export function createPlatformFactory(
73 parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null,
74 name: string,
75 providers: StaticProvider[] = [],
76): (extraProviders?: StaticProvider[]) => PlatformRef {
77 const desc = `Platform: ${name}`;
78 const marker = new InjectionToken(desc);
79 return (extraProviders: StaticProvider[] = []) => {
80 let platform = getPlatform();
81 if (!platform) {
82 const platformProviders: StaticProvider[] = [
83 ...providers,
84 ...extraProviders,
85 {provide: marker, useValue: true},
86 ];
87
88 platform =
89 parentPlatformFactory?.(platformProviders) ??
90 createPlatform(createPlatformInjector(platformProviders, desc));
91 }
92
93 return typeof ngServerMode !== 'undefined' && ngServerMode ? platform : assertPlatform(marker);
94 };
95}
96
97/**
98 * 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…