Import
import { RefSubject } from "@typed/fx";Access RefSubject.set 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 set: {
<A>(value: A): <E, R>(ref: RefSubject<A, E, R>) => Effect.Effect<A, E, R>;
<A, E, R>(ref: RefSubject<A, E, R>, a: A): Effect.Effect<A, E, R>;
};Why
Sets the value of a RefSubject. The transition is serialized at the RefSubject rather than
coordinated by callers or UI components.
Ownership and lifetime
Running set 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 count = yield* RefSubject.make(0)
// Set the value
yield* RefSubject.set(count, 10)
const value = yield* count
console.log(value) // 10
// Can also use pipe syntax
yield* count.pipe(RefSubject.set(20))
const newValue = yield* count
console.log(newValue) // 20
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.