MCPcopy
hub / github.com/angular/angular / runInContext

Method runInContext

packages/core/src/di/r3_injector.ts:303–321  ·  view source on GitHub ↗
(fn: () => ReturnT)

Source from the content-addressed store, hash-verified

301 }
302
303 override runInContext<ReturnT>(fn: () => ReturnT): ReturnT {
304 assertNotDestroyed(this);
305
306 const previousInjector = setCurrentInjector(this);
307 const previousInjectImplementation = setInjectImplementation(undefined);
308
309 let prevInjectContext: InjectorProfilerContext | undefined;
310 if (ngDevMode) {
311 prevInjectContext = setInjectorProfilerContext({injector: this, token: null});
312 }
313
314 try {
315 return fn();
316 } finally {
317 setCurrentInjector(previousInjector);
318 setInjectImplementation(previousInjectImplementation);
319 ngDevMode && setInjectorProfilerContext(prevInjectContext!);
320 }
321 }
322
323 override get<T>(
324 token: ProviderToken<T>,

Callers 3

TestCmpClass · 0.80
runSeriallyFunction · 0.80

Calls 5

setInjectImplementationFunction · 0.90
assertNotDestroyedFunction · 0.85
setCurrentInjectorFunction · 0.85
fnFunction · 0.50

Tested by 1

runSeriallyFunction · 0.64