- reduceSignal<T>(initialValue, callbackFn, options?): ReduceSignal<T, T>
Parameters
- initialValue: T
- callbackFn: ((prior: T, current: T) => T)
- (prior, current): T
Returns T
Optional
options: CreateSignalOptions<T>
- reduceSignal<T, U>(initialValue, callbackFn, options?): ReduceSignal<T, U>
Parameters
- initialValue: T
- callbackFn: ((prior: T, current: U) => T)
- (prior, current): T
Returns T
Optional
options: CreateSignalOptions<T>
Creates a WriteableSignal similar to array.reduce: Every time a value is set, callbackFn is run with the previous value to create a new value.
Param: initialValue
The signal's initial value
Param: callbackFn
The callback run when the signal is set that will create its value
Param: options
The equality function that will run after callbackFn
Returns
A writable signal whose output value is run through the callbackFn.
Example