Import
import { Sink } from "@typed/fx";Access Sink.reduce through the imported Sink export. Its declaration below describes the member.
This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.
Signatures
export declare function reduce<A, B, E>(ref: Ref.Ref<B>, f: (b: B, a: A) => B): Sink<A, E, never>;Why
An existing Ref provides an explicit, independently readable result location for consumer-side aggregation.
Ownership and lifetime
The caller owns the Ref. Each success returns a lazy atomic Ref.update; invoking onSuccess
does not update immediately. If the producer executes callback Effects serially, values reduce in
that execution order. Concurrent execution is still atomic but may be scheduled in a different
order than callback invocation. Failures are ignored and a thrown reducer exception is a defect.
Examples
import { Effect, Ref } from "effect"
import * as Sink from "@typed/fx/Sink"
const program = Effect.gen(function* () {
const total = yield* Ref.make(0)
return Sink.reduce(total, (sum, n: number) => sum + n)
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.