effect-io-ai

Package: effect
Module: PubSub

PubSub.isShutdownUnsafe

Checks synchronously whether shutdown has been called, returning true after shutdown and false otherwise.

When to use

Use when an immediate PubSub shutdown-state snapshot is needed outside effectful code and racing shutdown changes are acceptable.

Example (Checking shutdown synchronously)

import { PubSub } from "effect"

declare const pubsub: PubSub.PubSub<string>

// Unsafe synchronous shutdown check
const isDown = PubSub.isShutdownUnsafe(pubsub)
if (isDown) {
  console.log("PubSub is shutdown, cannot publish")
} else {
  console.log("PubSub is active")
}

Signature

declare const isShutdownUnsafe: <A>(self: PubSub<A>) => boolean

Source

Since v4.0.0