Import
import { Subject } from "@typed/fx";Access Subject.Service through the imported Subject 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 Service<Self, A, E = never>(): <const Id extends string>(id: Id) => Subject.Class<Self, Id, A, E>;Why
A named subject often represents an application-wide event boundary. Service keeps that
boundary type-safe and lets producers, consumers, and layers compose through Effect’s normal
service channel instead of a module-global mutable instance.
Ownership and lifetime
Defining the class acquires nothing. Calling its static make creates a layer backed by scoped
Subject.make; releasing the layer interrupts subscriptions and clears replay. Static Fx and
Sink operations require Self, then delegate to the installed subject. Invalid replay
capacities fail layer construction with Cause.IllegalArgumentError.
Examples
import { Effect } from "effect"
import { Fx } from "@typed/fx"
import * as Subject from "@typed/fx/Subject"
class Notifications extends Subject.Service<Notifications, string>()("Notifications") {}
const program = Effect.gen(function* () {
yield* Notifications.onSuccess("saved")
return yield* Fx.first(Notifications)
}).pipe(Effect.provide(Notifications.make(1)), Effect.scoped)Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.