effect-io-ai

Package: effect
Module: Scope

Scope.Closeable

A Closeable scope extends the base Scope interface with the ability to be closed, executing all registered finalizers.

Example (Closing a scope)

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

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

  // Add a finalizer
  yield* Scope.addFinalizer(scope, Console.log("Cleanup!"))

  // Scope can be closed
  yield* Scope.close(scope, Exit.void)
})

Signature

export interface Closeable extends Scope {
  readonly [CloseableTypeId]: typeof CloseableTypeId
}

Source

Since v2.0.0