Class DynArrayReducer<T>
Type Parameters
Hierarchy
- DynArrayReducer (view full)
Index
Constructors
Accessors
Methods
Constructors
constructor
- new
Dyn <T>(data?): DynArrayReducer<T>Array Reducer Initializes DynArrayReducer. 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
Optional
data: Iterable<T, any, any> | DynArrayData<T>Data iterable to store if array or copy otherwise.
Returns DynArrayReducer<T>
Accessors
data
- get data(): T[]
Returns the internal data of this instance. Be careful!
Note: if an array is set as initial data then that array is used as the internal data. If any changes are performed to the data externally do invoke
update
via DynArrayReducer.index withtrue
to recalculate the index and notify all subscribers.Returns T[]
The internal data.
derived
- get derived(): DynDerivedAPI<T[], number, T>
Returns DynDerivedAPI<T[], number, T>
Derived public API.
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<number, T>
Returns DynIndexerAPI<number, 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 DynArrayReducer.
Returns IterableIterator<T, any, any>
Iterator for data stored in DynArrayReducer.
destroy
Protected
initialize
setData
subscribe
- subscribe(handler): (() => void)
Add a subscriber to this DynArrayReducer instance.
Parameters
- handler: ((value: DynArrayReducer<T>) => void)
Callback function that is invoked on update / changes. Receives
this
reference.- (value): void
Parameters
- value: DynArrayReducer<T>
Returns void
Returns (() => void)
Unsubscribe function.
- (): void
Returns void
- handler: ((value: DynArrayReducer<T>) => void)
Provides a managed array with non-destructive reducing / filtering / sorting capabilities with subscription / Svelte store support.