Class DynMapReducer<K, T>
Type Parameters
Index
Constructors
Accessors
Methods
Constructors
constructor
- new
Dyn <K, T>(data?): DynMapReducer<K, T>Map Reducer Initializes DynMapReducer. Any iterable is supported for initial data. Take note that if
data
is an array it will be used as the host array and not copied. All non-array iterables otherwise create a new array / copy.Type Parameters
Parameters
Returns DynMapReducer<K, T>
Accessors
data
- get data(): Map<K, T>
Returns the internal data of this instance. Be careful!
Note: When a map is set as data then that map is used as the internal data. If any changes are performed to the data externally do invoke
update
via DynMapReducer.index withtrue
to recalculate the index and notify all subscribers.Returns Map<K, T>
The internal data.
derived
destroyed
- get destroyed(): boolean
Returns boolean
Returns whether this instance is destroyed.
filters
- get filters(): DynAdapterFilters<T>
Returns DynAdapterFilters<T>
The filters adapter.
index
- get index(): DynIndexerAPI<K, T>
Returns DynIndexerAPI<K, T>
Returns the Indexer public API.
length
- get length(): number
Gets the main data / items length.
Returns number
Main data / items length.
reversed
- get reversed(): boolean
Gets current reversed state.
Returns boolean
Reversed state.
- set reversed(reversed): void
Sets reversed state and notifies subscribers.
Parameters
- reversed: boolean
New reversed state.
Returns void
- reversed: boolean
sort
- get sort(): DynAdapterSort<T>
Returns DynAdapterSort<T>
The sort adapter.
Methods
[iterator]
- [iterator](): IterableIterator<T, any, any>
Provides an iterator for data stored in DynMapReducer.
Returns IterableIterator<T, any, any>
destroy
Protected
initialize
setData
subscribe
- subscribe(handler): (() => void)
Add a subscriber to this DynMapReducer instance.
Parameters
- handler: ((value: DynMapReducer<K, T>) => void)
Callback function that is invoked on update / changes. Receives
this
reference.- (value): void
Parameters
- value: DynMapReducer<K, T>
Returns void
Returns (() => void)
Unsubscribe function.
- (): void
Returns void
- handler: ((value: DynMapReducer<K, T>) => void)
Provides a managed Map with non-destructive reducing / filtering / sorting capabilities with subscription / Svelte store support.
Template: K,
T