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

Method resolveInjectorInitializers

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

@internal

()

Source from the content-addressed store, hash-verified

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