Package: effect
Module: TxPubSub
Creates a bounded TxPubSub with the specified capacity. When a subscriber’s queue is full, the publisher will retry the transaction until space is available.
Example (Creating a bounded pub/sub)
import { Effect, TxPubSub, TxQueue } from "effect"
const program = Effect.gen(function*() {
const hub = yield* TxPubSub.bounded<number>(16)
yield* Effect.scoped(
Effect.gen(function*() {
const sub = yield* TxPubSub.subscribe(hub)
yield* TxPubSub.publish(hub, 42)
const value = yield* TxQueue.take(sub)
console.log(value) // 42
})
)
})
Signature
declare const bounded: <A = never>(capacity: number) => Effect.Effect<TxPubSub<A>>
Since v2.0.0