effect-io-ai

Package: effect
Module: TxPubSub

TxPubSub.unbounded

Creates an unbounded TxPubSub with unlimited capacity. Messages are always accepted.

Example (Creating an unbounded pub/sub)

import { Effect, TxPubSub, TxQueue } from "effect"

const program = Effect.gen(function*() {
  const hub = yield* TxPubSub.unbounded<string>()

  yield* Effect.scoped(
    Effect.gen(function*() {
      const sub = yield* TxPubSub.subscribe(hub)
      yield* TxPubSub.publish(hub, "msg")
      const msg = yield* TxQueue.take(sub)
      console.log(msg) // "msg"
    })
  )
})

Signature

declare const unbounded: <A = never>() => Effect.Effect<TxPubSub<A>>

Source

Since v2.0.0