function / @typed/fx/Subject

unsafeMake

Immediately allocates a Subject with the requested replay capacity and manual ownership.

Package version
2.0.0-beta.7
Category
Subject construction
Since
1.0.0

Import

import { unsafeMake } from "@typed/fx/Subject";

Signatures

export declare function unsafeMake<A, E = never>(replay?: number): Subject<A, E>;

Why

unsafeMake is the escape hatch for owners that cannot acquire through an Effect Scope, such as a long-lived host object with its own explicit teardown. Prefer make inside Effect programs.

Ownership and lifetime

Allocation is synchronous and starts no fibers. The caller must execute interrupt to close subscribers and clear retained Exit values. Capacity 0 retains nothing, capacity 1 retains the latest publication, and larger capacities retain the newest window in FIFO replay order.

Errors

Invalid capacities throw Cause.IllegalArgumentError synchronously; this function has no typed Effect error channel. Publishing and subscribing use the E and service channels of the returned subject.

Examples

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

const events = Subject.unsafeMake<string>(10)

const shutdown = events.interrupt
const publish = events.onSuccess("ready").pipe(Effect.asVoid)

Other public imports

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

Source