interface / @typed/fx/Sink

Sink.Service

Describes a Sink available through an Effect Context service.

Package version
2.0.0-beta.13
Category
Sink services
Since
1.0.0
Member of
Sink

Import

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

Access Sink.Service through the imported Sink export. Its declaration below describes the member.

Signatures

interface Service<Self, Id extends string, A, E> extends Sink<A, E, Self> {
    readonly id: Id;
    readonly service: Context.Service<Self, Sink<A, E>>;
    readonly make: <R = never>(onFailure: (cause: Cause.Cause<E>) => Effect<unknown, never, R>, onSuccess: (value: A) => Effect<unknown, never, R>) => Layer<Self, never, Exclude<R, Scope>>;
}

Why

Producers can depend on a named consumer without receiving a concrete sink through every call.

Ownership and lifetime

The installed Layer owns the concrete callback closures. Calls resolve Self from the current Effect context; Layer scope owns any services captured while constructing them.

Property: id

Stable Context service identifier.

Property: id: Why

The literal ID names diagnostics and distinguishes the service tag.

Property: id: Ownership and lifetime

This immutable string acquires no resources and lives with the service class.

Property: make

Builds a Layer whose sink callbacks capture their construction services.

Property: make: Why

Callback dependencies are resolved once when the Layer is built rather than on every value.

Property: make: Ownership and lifetime

Layer scope owns captured services. Callback requirements exclude Scope because that scope is consumed during Layer construction.

Property: service

Effect Context reference used to install or retrieve the concrete sink.

Property: service: Why

The tag connects the class-shaped API to Effect’s Context and Layer ecosystem.

Property: service: Ownership and lifetime

The tag is static and resource-free; the currently provided Layer owns the concrete value.

Examples

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

class Events extends Sink.Service<Events, string>()("Events") {}
const EventsLive = Events.make(Effect.logError, Effect.log)

Other public imports

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

Source