import { AsyncReducer } from "https://deno.land/x/rimbu@1.1.0/mod.ts";
const { createOutput } = AsyncReducer;
Returns an AsyncReducer
of which the state and output types are the same.
Type Parameters
optional
O = IParameters
init: () => MaybePromise<O>
- the optionally lazy and/or promised initial state value
next: () => MaybePromise<O>
- returns (potentially asynchronously) the next state value based on the given inputs:
- current: the current state
- next: the current input value
- index: the input index value
- halt: function that, when called, ensures no more elements are passed to the reducer
optional
stateToResult: (state: O) => MaybePromise<O>- a potentially asynchronous function that converts the current state to an output value
optional
onClose: (state: O, error?: unknown) => MaybePromise<void>- (optional) a function that will be called when the reducer will no longer receive values