Package: effect
Module: Effect
Returns the current scope for resource management.
Example (Accessing the current scope)
import { Console, Effect } from "effect"
const program = Effect.gen(function*() {
const currentScope = yield* Effect.scope
yield* Console.log("Got scope for resource management")
// Use the scope to manually manage resources if needed
const resource = yield* Effect.acquireRelease(
Console.log("Acquiring resource").pipe(Effect.as("resource")),
() => Console.log("Releasing resource")
)
return resource
})
Effect.runPromise(Effect.scoped(program)).then(console.log)
// Output:
// Got scope for resource management
// Acquiring resource
// resource
// Releasing resource
Signature
declare const scope: Effect<Scope, never, Scope>
Since v2.0.0