type-alias / @typed/fx/Fx

Emit

Operations supplied to a callback producer for emitting values or ending its run.

Package version
2.0.0-beta.7
Category
Callback protocol
Since
1.0.0

Import

import { Emit } from "@typed/fx/Fx";

Signatures

export type Emit<A, E = never> = {
    succeed: (value: A) => Fiber<unknown, never>;
    failCause: (cause: Cause.Cause<E>) => Fiber<unknown, never>;
    fail: (error: E) => Fiber<unknown, never>;
    die: (error: unknown) => Fiber<unknown, never>;
    done: () => Fiber<unknown, never>;
};

Why

Callback sources need an explicit bridge into Sink operations while retaining the distinction between typed failures, defects, interruption causes, and completion.

Ownership and lifetime

An Emit is valid only for the active callback run. Every operation forks the corresponding sink Effect in that run’s scope and returns its Fiber; callers may inspect or interrupt that delivery. Retaining it after cleanup is unsupported.

Property: die

Starts delivery of one unexpected defect and returns the delivery fiber.

Property: die: Why

Programming defects remain outside the typed E channel.

Property: die: Ownership and lifetime

The active callback scope owns the returned fiber. The value is wrapped with Cause.die and forwarded to the sink.

Property: done

Requests early completion and returns the sink’s early-exit fiber.

Property: done: Why

Finite callback APIs need an explicit completion signal distinct from failure.

Property: done: Ownership and lifetime

The active callback scope owns the returned fiber. Early exit ends the run and causes callback cleanup registered by callback to execute.

Property: fail

Starts delivery of one typed failure and returns the delivery fiber.

Property: fail: Why

Expected callback errors enter E without being converted to defects.

Property: fail: Ownership and lifetime

The active callback scope owns the returned fiber. The error is wrapped with Cause.fail and forwarded to the sink.

Property: failCause

Starts delivery of a complete Effect Cause and returns the delivery fiber.

Property: failCause: Why

Typed failures, defects, and interruption remain structurally distinct.

Property: failCause: Ownership and lifetime

The active callback scope owns the returned fiber. This operation does not automatically call done; terminal behavior is determined by the sink.

Property: succeed

Starts delivery of one value and returns the delivery fiber.

Property: succeed: Why

Callback producers push values when they arrive instead of waiting to be pulled.

Property: succeed: Ownership and lifetime

The active callback scope owns the returned fiber; deliveries can overlap when succeed is called again before an earlier sink Effect completes.

Other public imports

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

Source