Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/common/internal.ts>AsyncReducer.create

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function AsyncReducer.create
import { AsyncReducer } from "https://deno.land/x/rimbu@0.13.0/common/internal.ts";
const { create } = AsyncReducer;

Returns an AsyncReducer with the given options:

Type Parameters

I
optional
O = I
optional
S = O

Parameters

  • the optionally lazy and/or promised initial state value
next: (
current: S,
next: I,
index: number,
halt: () => void,
) => 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