import { AsyncReducer } from "https://deno.land/x/rimbu@0.13.5/core/mod.ts";
const { createMono } = AsyncReducer;
Returns an AsyncReducer
of which the input, state, and output types are the same.
Parameters
init: AsyncOptLazy<T>
- the optionally lazy and/or promised initial state value
next: () => MaybePromise<T>
- 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: T) => MaybePromise<T>- a potentially asynchronous function that converts the current state to an output value
optional
onClose: (state: T, error?: unknown) => MaybePromise<void>- (optional) a function that will be called when the reducer will no longer receive values