The type of the value stored in state and produced by reduction.
The type of updates accepted by the reducer.
Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).
ReadonlyinputThe schema used to validate reducer inputs.
If not specified explicitly, this defaults to valueSchema.
Represents the type that may be provided as input on each update.
Optional ReadonlyjsonOptional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).
ReadonlyreducerThe reducer function that combines a current output value and an incoming input.
ReadonlyvalueThe schema that describes the type of value stored in state (i.e., after reduction).
Note: We use unknown for the input type to allow schemas with .default() wrappers,
where the input type includes undefined.
Represents the value stored after all reductions.
StaticisType guard to check if a value is a ReducedValue instance.
Type guard to check if a value is a ReducedValue instance.
Represents a state field whose value is computed and updated using a reducer function.
ReducedValue allows you to define accumulators, counters, aggregators, or other fields whose value is determined incrementally by applying a reducer to incoming updates.
Each time a new input is provided, the reducer function is called with the current output and the new input, producing an updated value. Input validation can be controlled separately from output validation by providing an explicit input schema.
Example
Example