Hyperlinkv0.8.0-beta.28

PubSub

PubSub.makeconsteffect/PubSub.ts:274
<A>(options: {
  readonly atomicPubSub: LazyArg<PubSub.Atomic<A>>
  readonly strategy: LazyArg<PubSub.Strategy<A>>
}): Effect.Effect<PubSub<A>>

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")
})
constructors
Source effect/PubSub.ts:27416 lines
export const make = <A>(
  options: {
    readonly atomicPubSub: LazyArg<PubSub.Atomic<A>>
    readonly strategy: LazyArg<PubSub.Strategy<A>>
  }
): Effect.Effect<PubSub<A>> =>
  Effect.sync(() =>
    makePubSubUnsafe(
      options.atomicPubSub(),
      new Map(),
      Scope.makeUnsafe(),
      Latch.makeUnsafe(false),
      MutableRef.make(false),
      options.strategy()
    )
  )
Referenced by 4 symbols