Class DynArrayReducerDerived<T>
Type Parameters
Implements
- DynDerivedReducer<T[], number, T>
Index
Constructors
Accessors
Methods
Constructors
constructor
- new DynArrayReducerDerived<T>(
array: DynDataHost<T[]>,
parentIndex: DynIndexerAPI<number, T>,
options: DynDataOptions<T>,
): DynArrayReducerDerived<T> Type Parameters
Parameters
- array: DynDataHost<T[]>
Data host array.
- parentIndex: DynIndexerAPI<number, T>
Parent indexer.
- options: DynDataOptions<T>
Any filters and sort functions to apply.
Returns DynArrayReducerDerived<T>
- array: DynDataHost<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 DynIndexerAPI.update with
true
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 whether this derived reducer is destroyed.
Returns boolean
filters
- get filters(): DynAdapterFilters<T>
Returns DynAdapterFilters<T>
The filters adapter.
index
- get index(): DynIndexerAPI<number, T>
Returns the Indexer public API.
Returns DynIndexerAPI<number, T>
Indexer API - is also iterable.
length
- get length(): number
Returns number
Main data / items length or indexed length.
reversed
- get reversed(): boolean
Returns boolean
Gets 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(): DynAdapterSort<T>
Returns DynAdapterSort<T>
The sort adapter.
Methods
[iterator]
- "[iterator]"(): IterableIterator<T, any, any>
Provides an iterator for data stored in DerivedArrayReducer.
Returns IterableIterator<T, any, any>
destroy
Protected
initialize
- initialize(optionsRest?: { [key: string]: any }): void
Protected
Provides a callback for custom derived reducers to initialize any data / custom configuration. This allows child classes to avoid implementing the constructor.
Parameters
Optional
optionsRest: { [key: string]: any }Any additional custom options passed beyond DynDataOptions.
Returns void
subscribe
- subscribe(handler: (value: DynArrayReducerDerived<T>) => void): () => void
Subscribe to this DerivedArrayReducer.
Parameters
- handler: (value: DynArrayReducerDerived<T>) => void
Callback function that is invoked on update / changes. Receives
this
reference.
Returns () => void
Unsubscribe function.
- handler: (value: DynArrayReducerDerived<T>) => void
Provides the base implementation derived reducer for arrays / DynArrayReducer.
Note: That you should never directly create an instance of a derived reducer, but instead use the DynArrayReducerDerived.initialize callback to set up any initial state in a custom derived reducer.