Interface DynAdapterFilters<T>
interface DynAdapterFilters<T> {
get length(): number;
[iterator](): void | IterableIterator<DynDataFilter<T>, any, any>;
add(...filters: (DynDataFilter<T> | DynFilterFn<T>)[]): void;
clear(): void;
remove(...filters: (DynDataFilter<T> | DynFilterFn<T>)[]): void;
removeBy(callback: ((id: any, filter: DynFilterFn<T>, weight: number) => boolean)): void;
removeById(...ids: any[]): void;
}
get length(): number;
[iterator](): void | IterableIterator<DynDataFilter<T>, any, any>;
add(...filters: (DynDataFilter<T> | DynFilterFn<T>)[]): void;
clear(): void;
remove(...filters: (DynDataFilter<T> | DynFilterFn<T>)[]): void;
removeBy(callback: ((id: any, filter: DynFilterFn<T>, weight: number) => boolean)): void;
removeById(...ids: any[]): void;
}
Type Parameters
Index
Accessors
Methods
Methods
[iterator]
- [iterator](): void | IterableIterator<DynDataFilter<T>, any, any>
Provides an iterator for filters.
Returns void | IterableIterator<DynDataFilter<T>, any, any>
add
- add(...filters): void
Parameters
Rest
...filters: (DynDataFilter<T> | DynFilterFn<T>)[]One or more filter functions / DynDataFilter to add.
Returns void
clear
remove
- remove(...filters): void
Parameters
Rest
...filters: (DynDataFilter<T> | DynFilterFn<T>)[]One or more filter functions / DynDataFilter to remove.
Returns void
removeBy
- remove
By (callback): void Remove filters by the provided callback. The callback takes 3 parameters:
id
,filter
, andweight
. Any truthy value returned will remove that filter.Parameters
- callback: ((id: any, filter: DynFilterFn<T>, weight: number) => boolean)
Callback function to evaluate each filter entry.
- (id, filter, weight): boolean
Parameters
- id: any
- filter: DynFilterFn<T>
- weight: number
Returns boolean
Returns void
- callback: ((id: any, filter: DynFilterFn<T>, weight: number) => boolean)
Provides the storage and sequencing of managed filters. Each filter added may be a bespoke function or a DynDataFilter object containing an
id
,filter
, andweight
attributes;filter
is the only required attribute.The
id
attribute can be anything that creates a unique ID for the filter; recommended strings or numbers. This allows filters to be removed by ID easily.The
weight
attribute is a number between 0 and 1 inclusive that allows filters to be added in a predictable order which is especially handy if they are manipulated at runtime. A lower weighted filter always runs before a higher weighted filter. For speed and efficiency always set the heavier / more inclusive filter with a lower weight; an example of this is a keyword / name that will filter out many entries making any further filtering faster. If no weight is specified the default of '1' is assigned and it is appended to the end of the filters list.This class forms the public API which is accessible from the
.filters
getter in the main reducer implementation.