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

Function executeOnDestroys

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

Calls onDestroy hooks for this view

(tView: TView, lView: LView)

Source from the content-addressed store, hash-verified

435
436/** Calls onDestroy hooks for this view */
437function executeOnDestroys(tView: TView, lView: LView): void {
438 ngDevMode && assertNotReactive(executeOnDestroys.name);
439 let destroyHooks: DestroyHookData | null;
440
441 if (tView != null && (destroyHooks = tView.destroyHooks) != null) {
442 for (let i = 0; i < destroyHooks.length; i += 2) {
443 const context = lView[destroyHooks[i] as number];
444
445 // Only call the destroy hook if the context has been requested.
446 if (!(context instanceof NodeInjectorFactory)) {
447 const toCall = destroyHooks[i + 1] as HookFn | HookData;
448
449 if (Array.isArray(toCall)) {
450 for (let j = 0; j < toCall.length; j += 2) {
451 const callContext = context[toCall[j] as number];
452 const hook = toCall[j + 1] as HookFn;
453 profiler(ProfilerEvent.LifecycleHookStart, callContext, hook);
454 try {
455 hook.call(callContext);
456 } finally {
457 profiler(ProfilerEvent.LifecycleHookEnd, callContext, hook);
458 }
459 }
460 } else {
461 profiler(ProfilerEvent.LifecycleHookStart, context, toCall);
462 try {
463 toCall.call(context);
464 } finally {
465 profiler(ProfilerEvent.LifecycleHookEnd, context, toCall);
466 }
467 }
468 }
469 }
470 }
471}
472
473/**
474 * 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