MCPcopy Index your code
hub / github.com/angular/angular / storeCleanupWithContext

Function storeCleanupWithContext

packages/core/src/render3/util/view_utils.ts:337–365  ·  view source on GitHub ↗
(
  tView: TView,
  lView: LView,
  context: any,
  cleanupFn: Function,
)

Source from the content-addressed store, hash-verified

335 * - Index of context we just saved in LView.cleanupInstances
336 */
337export function storeCleanupWithContext(
338 tView: TView,
339 lView: LView,
340 context: any,
341 cleanupFn: Function,
342): void {
343 const lCleanup = getOrCreateLViewCleanup(lView);
344
345 // Historically the `storeCleanupWithContext` was used to register both framework-level and
346 // user-defined cleanup callbacks, but over time those two types of cleanups were separated.
347 // This dev mode checks assures that user-level cleanup callbacks are _not_ stored in data
348 // structures reserved for framework-specific hooks.
349 ngDevMode &&
350 assertDefined(
351 context,
352 'Cleanup context is mandatory when registering framework-level destroy hooks',
353 );
354 lCleanup.push(context);
355
356 if (tView.firstCreatePass) {
357 getOrCreateTViewCleanup(tView).push(cleanupFn, lCleanup.length - 1);
358 } else {
359 // Make sure that no new framework-level cleanup functions are registered after the first
360 // template pass is done (and TView data structures are meant to fully constructed).
361 if (ngDevMode) {
362 Object.freeze(getOrCreateTViewCleanup(tView));
363 }
364 }
365}

Callers 1

createLQueryFunction · 0.90

Calls 4

assertDefinedFunction · 0.90
getOrCreateLViewCleanupFunction · 0.85
getOrCreateTViewCleanupFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…