Hyperlinkv0.8.0-beta.28

PubSub

PubSub.awaitShutdownconsteffect/PubSub.ts:861
<A>(self: PubSub<A>): Effect.Effect<void>

Waits until the queue is shutdown. The Effect returned by this method will not resume until the queue has been shutdown. If the queue is already shutdown, the Effect will resume right away.

Example (Waiting for shutdown)

import { Effect, Fiber, PubSub } from "effect"

const program = Effect.gen(function*() {
  const pubsub = yield* PubSub.bounded<string>(10)

  // Start a fiber that waits for shutdown
  const waiterFiber = yield* Effect.forkChild(
    Effect.gen(function*() {
      yield* PubSub.awaitShutdown(pubsub)
      console.log("PubSub has been shutdown!")
    })
  )

  // Do some work...
  yield* Effect.sleep("100 millis")

  // Shutdown the PubSub
  yield* PubSub.shutdown(pubsub)

  // The waiter will now complete
  yield* Fiber.join(waiterFiber)
})
lifecycle
Source effect/PubSub.ts:8611 lines
export const awaitShutdown = <A>(self: PubSub<A>): Effect.Effect<void> => self.shutdownHook.await