function / @typed/fx

Sink.make

Creates a Sink from success and failure callbacks.

Package version
2.0.0-beta.7
Category
Sink construction
Since
1.0.0
Member of
Sink

Import

import { Sink } from "@typed/fx";

Access Sink.make 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 make<A, E = never, R = never, R2 = R>(onFailure: (cause: Cause.Cause<E>) => Effect<unknown, never, R>, onSuccess: (value: A) => Effect<unknown, never, R2>): Sink<A, E, R | R2>;

Why

make is the smallest adapter from ordinary Effect programs to an Fx consumer.

Ownership and lifetime

Construction is pure and acquires nothing. Callback ordering and concurrency belong to the invoking producer; this adapter adds no queue. Callbacks are interrupted with their delivery owners. Requirements from both callbacks are combined in the returned sink; callback defects remain defects, while typed producer failures arrive through onFailure.

Examples

import { Effect } from "effect"
import * as Sink from "@typed/fx/Sink"

const sink = Sink.make(Effect.logError, (value: number) => Effect.log(value))

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source