import { AsyncReducer } from "https://deno.land/x/rimbu@0.13.0/common/index.ts";
const { create } = AsyncReducer;
Returns an AsyncReducer
with the given options:
Parameters
init: AsyncOptLazy<S>
- the optionally lazy and/or promised initial state value
next: () => MaybePromise<S>
- 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
stateToResult: (state: S) => MaybePromise<O>
- a potentially asynchronous function that converts the current state to an output value
optional
onClose: (state: S, error?: unknown) => MaybePromise<void>- (optional) a function that will be called when the reducer will no longer receive values