Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e975fe

Browse files
committed
refactor(template): rename viewCacheSize to templateCacheSize
1 parent fbc5177 commit 7e975fe

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

apps/docs/docs/template/api/virtual-scrolling.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ all pre-packaged ScrollStrategies as well as control the majority of inputs.
9292
- configurable frame budget (defaults to 60 FPS)
9393
- Super efficient layouting with css transformations
9494
- Scoped layouting with css containment
95-
- Define a viewCache in order to re-use views instead of re-creating them
95+
- Define a templateCache in order to re-use views instead of re-creating them
9696
- triggers change-detection on `EmbeddedView` level
9797
- Zone-agnostic, opt-out of `NgZone` with `patchZone`
9898
- 3 Configurable `RxVirtualScrollStrategy` providing the core logic to calculate the viewRange and position DOM
@@ -433,14 +433,14 @@ Read more about the concurrent mode in the [concurrent strategies section](https
433433

434434
#### Inputs
435435

436-
| Input | Type | description |
437-
| ---------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
438-
| `trackBy` | `keyof T` or `(index: number, item: T) => any` | Identifier function for items. `rxVirtualFor` provides a shorthand where you can name the property directly. |
439-
| `patchZone` | `boolean` | _default: `true`_ if set to `false`, the `RxVirtualForDirective` will operate out of `NgZone`. See [NgZone optimizations](https://www.rx-angular.io/docs/template/performance-issues/ngzone-optimizations) |
440-
| `parent` | `boolean` | _default: `false`_ if set to `false`, the `RxVirtualForDirective` won't inform its host component about changes being made to the template. More performant, `@ViewChild` and `@ContentChild` queries won't work. [Handling view and content queries](https://www.rx-angular.io/docs/template/performance-issues/handling-view-and-content-queries) |
441-
| `strategy` | `Observable<RxStrategyNames \ string> \ RxStrategyNames \ string>` | _default: `normal`_ configure the `RxStrategyRenderStrategy` used to detect changes. [Render Strategies](https://www.rx-angular.io/docs/cdk/render-strategies) |
442-
| `renderCallback` | `Subject<U>` | giving the developer the exact timing when the `RxVirtualForDirective` created, updated, removed its template. Useful for situations where you need to know when rendering is done. |
443-
| `viewCacheSize` | `number` | _default: `20`_ Controls the amount if views held in cache for later re-use when a user is scrolling the list If this is set to 0, `rxVirtualFor` won't cache any view, thus destroying & re-creating very often on scroll events. |
436+
| Input | Type | description |
437+
| ------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
438+
| `trackBy` | `keyof T` or `(index: number, item: T) => any` | Identifier function for items. `rxVirtualFor` provides a shorthand where you can name the property directly. |
439+
| `patchZone` | `boolean` | _default: `true`_ if set to `false`, the `RxVirtualForDirective` will operate out of `NgZone`. See [NgZone optimizations](https://www.rx-angular.io/docs/template/performance-issues/ngzone-optimizations) |
440+
| `parent` | `boolean` | _default: `false`_ if set to `false`, the `RxVirtualForDirective` won't inform its host component about changes being made to the template. More performant, `@ViewChild` and `@ContentChild` queries won't work. [Handling view and content queries](https://www.rx-angular.io/docs/template/performance-issues/handling-view-and-content-queries) |
441+
| `strategy` | `Observable<RxStrategyNames \ string> \ RxStrategyNames \ string>` | _default: `normal`_ configure the `RxStrategyRenderStrategy` used to detect changes. [Render Strategies](https://www.rx-angular.io/docs/cdk/render-strategies) |
442+
| `renderCallback` | `Subject<U>` | giving the developer the exact timing when the `RxVirtualForDirective` created, updated, removed its template. Useful for situations where you need to know when rendering is done. |
443+
| `templateCacheSize` | `number` | _default: `20`_ Controls the amount if views held in cache for later re-use when a user is scrolling the list If this is set to 0, `rxVirtualFor` won't cache any view, thus destroying & re-creating very often on scroll events. |
444444

445445
### RxVirtualScrollViewportComponent
446446

@@ -631,7 +631,7 @@ import { RX_VIRTUAL_SCROLL_DEFAULT_OPTIONS } from '@rx-angular/template/experime
631631
useValue: { // should be of type `RxVirtualScrollDefaultOptions`
632632
runwayItems: 50,
633633
// turn off cache by default
634-
viewCacheSize: 0
634+
templateCacheSize: 0
635635
}
636636
}]
637637
})
@@ -641,7 +641,7 @@ import { RX_VIRTUAL_SCROLL_DEFAULT_OPTIONS } from '@rx-angular/template/experime
641641

642642
```ts
643643
/* determines how many templates can be cached and re-used on rendering */
644-
const DEFAULT_VIEW_CACHE_SIZE = 20;
644+
const DEFAULT_TEMPLATE_CACHE_SIZE = 20;
645645
/* determines how many views will be rendered in scroll direction */
646646
const DEFAULT_ITEM_SIZE = 50;
647647
/* determines how many views will be rendered in the opposite scroll direction */
@@ -655,7 +655,7 @@ const DEFAULT_RUNWAY_ITEMS_OPPOSITE = 2;
655655
```ts
656656
export interface RxVirtualScrollDefaultOptions {
657657
/* determines how many templates can be cached and re-used on rendering, defaults to 20 */
658-
viewCacheSize?: number;
658+
templateCacheSize?: number;
659659
/* determines how many views will be rendered in scroll direction, defaults to 15 */
660660
runwayItems?: number;
661661
/* determines how many views will be rendered in the opposite scroll direction, defaults to 5 */

libs/template/experimental/virtual-scrolling/src/lib/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface TemplateSettings<Implicit, Context, ComputedContext> {
2525
templateRef: TemplateRef<Context>;
2626
createViewContext: CreateViewContext<Implicit, Context, ComputedContext>;
2727
updateViewContext: UpdateViewContext<Implicit, Context, ComputedContext>;
28-
viewCacheSize: number;
28+
templateCacheSize: number;
2929
}
3030

3131
export interface ListRange {

libs/template/experimental/virtual-scrolling/src/lib/virtual-for.directive.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import {
6060
RxVirtualListTemplateManager,
6161
} from './virtual-list-template-manager';
6262
import {
63-
DEFAULT_VIEW_CACHE_SIZE,
63+
DEFAULT_TEMPLATE_CACHE_SIZE,
6464
RX_VIRTUAL_SCROLL_DEFAULT_OPTIONS,
6565
} from './virtual-scroll.config';
6666

@@ -324,8 +324,8 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
324324
* scrolling the list. If this is set to 0, `rxVirtualFor` won't cache any view,
325325
* thus destroying & re-creating very often on scroll events.
326326
*/
327-
@Input('rxVirtualForViewCacheSize') viewCacheSize =
328-
this.defaults?.viewCacheSize || DEFAULT_VIEW_CACHE_SIZE;
327+
@Input('rxVirtualForTemplateCacheSize') templateCacheSize =
328+
this.defaults?.templateCacheSize || DEFAULT_TEMPLATE_CACHE_SIZE;
329329

330330
/**
331331
* @description
@@ -605,7 +605,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
605605
templateRef: this.template,
606606
createViewContext: this.createViewContext.bind(this),
607607
updateViewContext: this.updateViewContext.bind(this),
608-
viewCacheSize: this.viewCacheSize,
608+
templateCacheSize: this.templateCacheSize,
609609
});
610610
this.render()
611611
.pipe(takeUntil(this._destroy$))

libs/template/experimental/virtual-scrolling/src/lib/virtual-list-template-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function createVirtualListTemplateManager<
4646
templateRef,
4747
createViewContext,
4848
updateViewContext,
49-
viewCacheSize,
49+
templateCacheSize,
5050
}: TemplateSettings<T, C, any>): RxVirtualListTemplateManager<T, C> {
5151
let _viewCache: EmbeddedViewRef<C>[] = [];
5252
let itemCount = 0;
@@ -143,7 +143,7 @@ export function createVirtualListTemplateManager<
143143
* destroyed.
144144
*/
145145
function _maybeCacheView(view: EmbeddedViewRef<C>) {
146-
if (_viewCache.length < viewCacheSize) {
146+
if (_viewCache.length < templateCacheSize) {
147147
_viewCache.push(view);
148148
return true;
149149
} else {

libs/template/experimental/virtual-scrolling/src/lib/virtual-scroll.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { InjectionToken } from '@angular/core';
22

33
export interface RxVirtualScrollDefaultOptions {
44
/* determines how many templates can be cached and re-used on rendering, defaults to 20 */
5-
viewCacheSize?: number;
5+
templateCacheSize?: number;
66
/* determines how many views will be rendered in scroll direction, defaults to 15 */
77
runwayItems?: number;
88
/* determines how many views will be rendered in the opposite scroll direction, defaults to 5 */
@@ -25,13 +25,13 @@ export function RX_VIRTUAL_SCROLL_DEFAULT_OPTIONS_FACTORY(): RxVirtualScrollDefa
2525
return {
2626
runwayItems: DEFAULT_RUNWAY_ITEMS,
2727
runwayItemsOpposite: DEFAULT_RUNWAY_ITEMS_OPPOSITE,
28-
viewCacheSize: DEFAULT_VIEW_CACHE_SIZE,
28+
templateCacheSize: DEFAULT_TEMPLATE_CACHE_SIZE,
2929
itemSize: DEFAULT_ITEM_SIZE,
3030
};
3131
}
3232

3333
/** @internal */
34-
export const DEFAULT_VIEW_CACHE_SIZE = 20;
34+
export const DEFAULT_TEMPLATE_CACHE_SIZE = 20;
3535
/** @internal */
3636
export const DEFAULT_ITEM_SIZE = 50;
3737
/** @internal */

libs/template/experimental/virtual-scrolling/tests/autosize.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function mountAutoSize(
6666
*rxVirtualFor="
6767
let item of items;
6868
renderCallback: renderCallback;
69-
viewCacheSize: viewCache;
69+
templateCacheSize: viewCache;
7070
strategy: strategy;
7171
trackBy: trackBy;
7272
"

libs/template/experimental/virtual-scrolling/tests/dynamic-size.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function mountDynamicSize(
5959
*rxVirtualFor="
6060
let item of items;
6161
renderCallback: renderCallback;
62-
viewCacheSize: viewCache;
62+
templateCacheSize: viewCache;
6363
strategy: strategy;
6464
trackBy: trackBy;
6565
"

libs/template/experimental/virtual-scrolling/tests/fixed-size.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function mountFixedSize(
5252
*rxVirtualFor="
5353
let item of items;
5454
renderCallback: renderCallback;
55-
viewCacheSize: viewCache;
55+
templateCacheSize: viewCache;
5656
strategy: strategy;
5757
trackBy: trackBy;
5858
"

libs/template/experimental/virtual-scrolling/tests/fixtures.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
DEFAULT_ITEM_SIZE,
1515
DEFAULT_RUNWAY_ITEMS,
1616
DEFAULT_RUNWAY_ITEMS_OPPOSITE,
17-
DEFAULT_VIEW_CACHE_SIZE,
17+
DEFAULT_TEMPLATE_CACHE_SIZE,
1818
} from '../src/lib/virtual-scroll.config';
1919

2020
function randomContent(minLength = 1, maxLength = 50) {
@@ -83,7 +83,7 @@ export const defaultMountConfig: VirtualScrollMountConfig<Item> = {
8383
runwayItems: DEFAULT_RUNWAY_ITEMS,
8484
runwayItemsOpposite: DEFAULT_RUNWAY_ITEMS_OPPOSITE,
8585
itemSize: DEFAULT_ITEM_SIZE,
86-
viewCache: DEFAULT_VIEW_CACHE_SIZE,
86+
viewCache: DEFAULT_TEMPLATE_CACHE_SIZE,
8787
containerHeight: 300,
8888
} as const;
8989
export const defaultItemLength = 500;

0 commit comments

Comments
 (0)