effect-io-ai

Package: effect
Module: PubSub

PubSub.make

Creates a PubSub with a custom atomic implementation and strategy.

Example (Creating a PubSub with a custom strategy)

import { Effect, PubSub } from "effect"

const program = Effect.gen(function*() {
  // Create custom PubSub with specific atomic implementation and strategy
  const pubsub = yield* PubSub.make<string>({
    atomicPubSub: () => PubSub.makeAtomicBounded(100),
    strategy: () => new PubSub.BackPressureStrategy()
  })

  // Use the created PubSub
  yield* PubSub.publish(pubsub, "Hello")
})

Signature

declare const make: <A>(options: { readonly atomicPubSub: LazyArg<PubSub.Atomic<A>>; readonly strategy: LazyArg<PubSub.Strategy<A>>; }) => Effect.Effect<PubSub<A>>

Source

Since v4.0.0