Import
import { RefSubject } from "@typed/fx";Access RefSubject.runUpdates through the imported RefSubject 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 runUpdates: {
<A, E, R, B, E2, R2, R3 = never, E3 = never, C = never>(f: (ref: GetSetDelete<A, E, R>) => Effect.Effect<B, E2, R2>, options?: {
readonly onInterrupt: (value: A) => Effect.Effect<C, E3, R3>;
readonly value?: "initial" | "current";
}): (ref: RefSubject<A, E, R>) => Effect.Effect<B, E | E2 | E3, R | R2 | R3>;
<A, E, R, B, E2, R2, R3 = never, E3 = never, C = never>(ref: RefSubject<A, E, R>, f: (ref: GetSetDelete<A, E, R>) => Effect.Effect<B, E2, R2>, options?: {
readonly onInterrupt: (value: A) => Effect.Effect<C, E3, R3>;
readonly value?: "initial" | "current";
}): Effect.Effect<B, E | E2 | E3, R | R2 | R3>;
};Why
Runs an effect that can modify a RefSubject transactionally, with optional interrupt handling.
The transition is serialized at the RefSubject rather than coordinated by callers or UI
components.
Ownership and lifetime
Running run updates performs one serialized subject transition and resolves with its committed value. It acquires no resource; failures and services remain those of the source ref.
Examples
import { Effect } from "effect"
import * as RefSubject from "@typed/fx/RefSubject"
const program = Effect.gen(function* () {
const balance = yield* RefSubject.make(100)
// Transfer money atomically with interrupt handling
yield* RefSubject.runUpdates(
balance,
(ref) =>
Effect.gen(function* () {
const current = yield* ref.get
if (current >= 50) {
yield* ref.set(current - 50)
return "Transfer successful"
}
return "Insufficient funds"
}),
{
onInterrupt: (value) => Effect.sync(() => console.log(`Interrupted at balance: ${value}`)),
value: "initial"
}
)
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.