Import
import { Sink } from "@typed/fx/Sink";Access Sink.WithState through the imported Sink export. Its declaration below describes the member.
Signatures
interface WithState<A, E, R, B> extends WithEarlyExit<A, E, R> {
readonly state: Ref<B>;
}Why
Stateful consumers can accumulate values without moving that state into the producer.
Ownership and lifetime
The surrounding withState invocation creates and owns the Ref. It remains reachable only for
that invocation; callback ordering determines the order of state updates.
Property: state
Mutable state created for the current consumer invocation.
Property: state: Why
Stateful callback logic can use Effect’s atomic Ref operations directly.
Property: state: Ownership and lifetime
withState creates this Ref for one execution; it is not shared with later executions.
Examples
import { Ref } from "effect"
import type * as Sink from "@typed/fx/Sink"
const increment = (sink: Sink.Sink.WithState<number, never, never, number>) =>
Ref.update(sink.state, (n) => n + 1)Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.