Package: effect
Module: TxSubscriptionRef
Sets the value of the TxSubscriptionRef and publishes the new value to all subscribers.
When to use
Use to replace the current TxSubscriptionRef value with a known value and
publish it.
Example (Setting a new value)
import { Effect, TxSubscriptionRef } from "effect"
const program = Effect.gen(function*() {
const ref = yield* TxSubscriptionRef.make(0)
yield* TxSubscriptionRef.set(ref, 42)
console.log(yield* TxSubscriptionRef.get(ref)) // 42
})
See
update for deriving the new value from the current valuegetAndSet for setting while returning the previous valueSignature
declare const set: { <A>(value: A): (self: TxSubscriptionRef<A>) => Effect.Effect<void>; <A>(self: TxSubscriptionRef<A>, value: A): Effect.Effect<void>; }
Since v3.10.0