[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | import { IterableChanges, ViewContainerRef } from '@angular/core';
|
---|
| 9 | import { _ViewRepeater, _ViewRepeaterItemChanged, _ViewRepeaterItemContext, _ViewRepeaterItemContextFactory, _ViewRepeaterItemValueResolver } from './view-repeater';
|
---|
| 10 | /**
|
---|
| 11 | * A repeater that caches views when they are removed from a
|
---|
| 12 | * {@link ViewContainerRef}. When new items are inserted into the container,
|
---|
| 13 | * the repeater will reuse one of the cached views instead of creating a new
|
---|
| 14 | * embedded view. Recycling cached views reduces the quantity of expensive DOM
|
---|
| 15 | * inserts.
|
---|
| 16 | *
|
---|
| 17 | * @template T The type for the embedded view's $implicit property.
|
---|
| 18 | * @template R The type for the item in each IterableDiffer change record.
|
---|
| 19 | * @template C The type for the context passed to each embedded view.
|
---|
| 20 | */
|
---|
| 21 | export declare class _RecycleViewRepeaterStrategy<T, R, C extends _ViewRepeaterItemContext<T>> implements _ViewRepeater<T, R, C> {
|
---|
| 22 | /**
|
---|
| 23 | * The size of the cache used to store unused views.
|
---|
| 24 | * Setting the cache size to `0` will disable caching. Defaults to 20 views.
|
---|
| 25 | */
|
---|
| 26 | viewCacheSize: number;
|
---|
| 27 | /**
|
---|
| 28 | * View cache that stores embedded view instances that have been previously stamped out,
|
---|
| 29 | * but don't are not currently rendered. The view repeater will reuse these views rather than
|
---|
| 30 | * creating brand new ones.
|
---|
| 31 | *
|
---|
| 32 | * TODO(michaeljamesparsons) Investigate whether using a linked list would improve performance.
|
---|
| 33 | */
|
---|
| 34 | private _viewCache;
|
---|
| 35 | /** Apply changes to the DOM. */
|
---|
| 36 | applyChanges(changes: IterableChanges<R>, viewContainerRef: ViewContainerRef, itemContextFactory: _ViewRepeaterItemContextFactory<T, R, C>, itemValueResolver: _ViewRepeaterItemValueResolver<T, R>, itemViewChanged?: _ViewRepeaterItemChanged<R, C>): void;
|
---|
| 37 | detach(): void;
|
---|
| 38 | /**
|
---|
| 39 | * Inserts a view for a new item, either from the cache or by creating a new
|
---|
| 40 | * one. Returns `undefined` if the item was inserted into a cached view.
|
---|
| 41 | */
|
---|
| 42 | private _insertView;
|
---|
| 43 | /** Detaches the view at the given index and inserts into the view cache. */
|
---|
| 44 | private _detachAndCacheView;
|
---|
| 45 | /** Moves view at the previous index to the current index. */
|
---|
| 46 | private _moveView;
|
---|
| 47 | /**
|
---|
| 48 | * Cache the given detached view. If the cache is full, the view will be
|
---|
| 49 | * destroyed.
|
---|
| 50 | */
|
---|
| 51 | private _maybeCacheView;
|
---|
| 52 | /** Inserts a recycled view from the cache at the given index. */
|
---|
| 53 | private _insertViewFromCache;
|
---|
| 54 | }
|
---|