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

Method runInContext

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

Source from the content-addressed store, hash-verified

305
306 // 3p-only-start
307 override runInContext<ReturnT>(fn: () => ReturnT): ReturnT {
308 assertNotDestroyed(this);
309
310 const previousInjector = setCurrentInjector(this);
311 const previousInjectImplementation = setInjectImplementation(undefined);
312
313 let prevInjectContext: InjectorProfilerContext | undefined;
314 if (ngDevMode) {
315 prevInjectContext = setInjectorProfilerContext({injector: this, token: null});
316 }
317
318 try {
319 return fn();
320 } finally {
321 setCurrentInjector(previousInjector);
322 setInjectImplementation(previousInjectImplementation);
323 ngDevMode && setInjectorProfilerContext(prevInjectContext!);
324 }
325 }
326 // 3p-only-end
327
328 override get<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