Class DynMapReducer<K, T>
Type Parameters
Index
Constructors
Accessors
Methods
Constructors
constructor
- new DynMapReducer<K = unknown, T = unknown>(
data?: Map<K, T> | MapReducer<K, T>,
): DynMapReducer<K, T> 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
- get derived(): DynReducer.API.DerivedMap<K, T>
Returns DynReducer.API.DerivedMap<K, T>
Derived public API.
destroyed
- get destroyed(): boolean
Returns boolean
Returns whether this instance is destroyed.
filters
- get filters(): DynReducer.API.Filters<T>
Returns DynReducer.API.Filters<T>
The filters adapter.
index
length
- get length(): number
Returns number
Returns the main data items or indexed items length.
reversed
- get reversed(): boolean
Returns boolean
Returns current reversed state.
- set reversed(reversed: boolean): void
Sets reversed state and notifies subscribers.
Parameters
- reversed: boolean
New reversed state.
Returns void
- reversed: boolean
sort
- get sort(): DynReducer.API.Sort<T>
Returns DynReducer.API.Sort<T>
The sort adapter.
Methods
[iterator]
- "[iterator]"(): IterableIterator<T>
Provides an iterator for data stored in DynMapReducer.
Returns IterableIterator<T>
Iterator for data stored in DynMapReducer.
destroy
Protected
initialize
- initialize(optionsRest?: { [key: string]: any }): void
Protected
Provides a callback for custom reducers to initialize any data / custom configuration. Depending on the consumer of
dynamic-reducer
this may be utilized allowing child classes to avoid implementing the constructor.Parameters
Optional
optionsRest: { [key: string]: any }Any additional custom options passed beyond DynReducer.Options.Common.
Returns void
Provides a managed Map with non-destructive reducing / filtering / sorting capabilities with subscription / Svelte store support allowing for a Map to be treated like an iterable list.
Note:
unknown
ensures stricter type checking, preventing unintended operations on the data.Example