add trackBy function

This commit is contained in:
Dan Percic 2021-10-28 23:05:00 +03:00
parent defdc2af4e
commit 488d3d5c2c
3 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,6 @@
export interface IListable {
readonly id: string;
import { ITrackable } from './trackable';
export interface IListable extends ITrackable {
readonly searchKey: string;
readonly routerLink?: string;
}

View File

@ -0,0 +1,3 @@
export interface ITrackable {
readonly id: string;
}

View File

@ -1,4 +1,5 @@
import { tap } from 'rxjs/operators';
import { ITrackable } from '../listing/models/trackable';
export function capitalize(value: string): string {
if (!value) {
@ -25,3 +26,7 @@ export function toNumber(str: string): number {
return 0;
}
}
export function trackBy() {
return <T extends ITrackable>(index: number, item: T): string => item.id;
}