MCPcopy
hub / github.com/angular/angular / resolveInjectorInitializers

Method resolveInjectorInitializers

packages/core/src/di/r3_injector.ts:426–455  ·  view source on GitHub ↗

@internal

()

Source from the content-addressed store, hash-verified

424
425 /** @internal */
426 resolveInjectorInitializers() {
427 const prevConsumer = setActiveConsumer(null);
428 const previousInjector = setCurrentInjector(this);
429 const previousInjectImplementation = setInjectImplementation(undefined);
430 let prevInjectContext: InjectorProfilerContext | undefined;
431 if (ngDevMode) {
432 prevInjectContext = setInjectorProfilerContext({injector: this, token: null});
433 }
434
435 try {
436 const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, {self: true});
437 if (ngDevMode && !Array.isArray(initializers)) {
438 throw new RuntimeError(
439 RuntimeErrorCode.INVALID_MULTI_PROVIDER,
440 'Unexpected type of the `ENVIRONMENT_INITIALIZER` token value ' +
441 `(expected an array, but got ${typeof initializers}). ` +
442 'Please check that the `ENVIRONMENT_INITIALIZER` token is configured as a ' +
443 '`multi: true` provider.',
444 );
445 }
446 for (const initializer of initializers) {
447 initializer();
448 }
449 } finally {
450 setCurrentInjector(previousInjector);
451 setInjectImplementation(previousInjectImplementation);
452 ngDevMode && setInjectorProfilerContext(prevInjectContext!);
453 setActiveConsumer(prevConsumer);
454 }
455 }
456
457 override toString() {
458 if (ngDevMode) {

Callers 1

constructorMethod · 0.95

Calls 6

getMethod · 0.95
setActiveConsumerFunction · 0.90
setInjectImplementationFunction · 0.90
setCurrentInjectorFunction · 0.85
isArrayMethod · 0.80

Tested by

no test coverage detected