variable / @typed/fx

Push.make

Couples a Sink input with an independent Fx output.

The result forwards each input callback directly to sink and delegates every output subscription to fx. It does not connect the two values, change output cardinality or ordering, buffer inputs, or start either side eagerly.

Package version
2.0.0-beta.7
Category
Push construction
Since
1.0.0
Member of
Push

Import

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

Access Push.make through the imported Push 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 const make: {
    <B, E2, R2>(fx: Fx.Fx<B, E2, R2>): <A, E, R>(sink: Sink.Sink<A, E, R>) => Push<A, E, R, B, E2, R2>;
    <A, E, R, B, E2, R2>(sink: Sink.Sink<A, E, R>, fx: Fx.Fx<B, E2, R2>): Push<A, E, R, B, E2, R2>;
};

Why

make is the explicit boundary where a command consumer and event producer become one bidirectional capability without hiding either contract.

Ownership and lifetime

Construction is allocation-free apart from the wrapper. Each input callback is owned by its caller; each output run is owned by the wrapped Fx run and inherits its interruption, Scope, cleanup, failures, and services.

Examples

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

const received: Array<number> = []
const sink = Sink.make(() => Effect.void, (value: number) =>
  Effect.sync(() => received.push(value))
)
const push = Push.make(sink, Fx.fromIterable(["ready", "done"]))

const program = Effect.gen(function* () {
  yield* push.onSuccess(42) // acknowledges the Sink callback
  const output = yield* Fx.collectAll(push)
  return { received, output }
}).pipe(Effect.scoped)

Other public imports

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

Source