effect-io-ai

Package: effect
Module: Scope

Scope.State.Closed

Represents a closed scope state where finalizers have been executed and the scope is no longer accepting new resources.

Example (Inspecting a closed scope state)

import { Effect, Exit, Scope } from "effect"

const program = Effect.gen(function*() {
  const scope = yield* Scope.make()

  // Close the scope
  yield* Scope.close(scope, Exit.succeed("Done"))

  // Check if scope is closed
  if (scope.state._tag === "Closed") {
    console.log("Scope is closed")
    console.log(scope.state.exit) // The exit value used to close the scope
  }
})

Signature

type Closed = {
    readonly _tag: "Closed"
    readonly exit: Exit<any, any>
  }

Source

Since v4.0.0