MCPcopy
hub / github.com/angular/angular / executeOnDestroys

Function executeOnDestroys

packages/core/src/render3/node_manipulation.ts:431–465  ·  view source on GitHub ↗

Calls onDestroy hooks for this view

(tView: TView, lView: LView)

Source from the content-addressed store, hash-verified

429
430/** Calls onDestroy hooks for this view */
431function executeOnDestroys(tView: TView, lView: LView): void {
432 ngDevMode && assertNotReactive(executeOnDestroys.name);
433 let destroyHooks: DestroyHookData | null;
434
435 if (tView != null && (destroyHooks = tView.destroyHooks) != null) {
436 for (let i = 0; i < destroyHooks.length; i += 2) {
437 const context = lView[destroyHooks[i] as number];
438
439 // Only call the destroy hook if the context has been requested.
440 if (!(context instanceof NodeInjectorFactory)) {
441 const toCall = destroyHooks[i + 1] as HookFn | HookData;
442
443 if (Array.isArray(toCall)) {
444 for (let j = 0; j < toCall.length; j += 2) {
445 const callContext = context[toCall[j] as number];
446 const hook = toCall[j + 1] as HookFn;
447 profiler(ProfilerEvent.LifecycleHookStart, callContext, hook);
448 try {
449 hook.call(callContext);
450 } finally {
451 profiler(ProfilerEvent.LifecycleHookEnd, callContext, hook);
452 }
453 }
454 } else {
455 profiler(ProfilerEvent.LifecycleHookStart, context, toCall);
456 try {
457 toCall.call(context);
458 } finally {
459 profiler(ProfilerEvent.LifecycleHookEnd, context, toCall);
460 }
461 }
462 }
463 }
464 }
465}
466
467/**
468 * Returns a native element if a node can be inserted into the given parent.

Callers 1

cleanUpViewFunction · 0.85

Calls 3

assertNotReactiveFunction · 0.90
profilerFunction · 0.90
isArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…