function / @typed/fx/Sink

Service

Defines a class-shaped Effect Context service for a Sink.

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

Import

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

Signatures

export declare function Service<Self, A, E = never>(): <const Id extends string>(id: Id) => Sink.Class<Self, Id, A, E>;

Why

A service sink lets producers emit toward an application capability while Layers choose the concrete destination, such as logging, persistence, or UI output.

Ownership and lifetime

Definition is pure. Class.make captures its construction context into the sink callbacks and returns a Layer; providing that Layer controls availability and cleanup of captured scoped services. Each static callback lookup uses the current Effect context.

Examples

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

class Output extends Sink.Service<Output, string>()("Output") {}
const OutputLive = Output.make(Effect.logError, Effect.log)
const program = Output.onSuccess("ready").pipe(Effect.provide(OutputLive))

Other public imports

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

Source