/** * @since 1.0.0 */ import type * as Context from "@effect/data/Context"; import type { Pipeable } from "@effect/data/Pipeable"; import type * as Effect from "@effect/io/Effect"; import type * as ExecutionStrategy from "@effect/io/ExecutionStrategy"; import type * as Exit from "@effect/io/Exit"; /** * @since 1.0.0 * @category symbols */ export declare const ScopeTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type ScopeTypeId = typeof ScopeTypeId; /** * @since 1.0.0 * @category symbols */ export declare const CloseableScopeTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type CloseableScopeTypeId = typeof CloseableScopeTypeId; /** * @since 1.0.0 * @category models */ export interface Scope extends Pipeable { readonly [ScopeTypeId]: ScopeTypeId; readonly strategy: ExecutionStrategy.ExecutionStrategy; } /** * @since 1.0.0 * @category models */ export interface CloseableScope extends Scope, Pipeable { readonly [CloseableScopeTypeId]: CloseableScopeTypeId; } /** * @since 1.0.0 * @category context */ export declare const Scope: Context.Tag; /** * @since 1.0.0 */ export declare namespace Scope { /** * @since 1.0.0 * @category model */ type Finalizer = (exit: Exit.Exit) => Effect.Effect; /** * @since 1.0.0 * @category model */ type Closeable = CloseableScope; } /** * Adds a finalizer to this scope. The finalizer is guaranteed to be run when * the scope is closed. * * @since 1.0.0 * @category utils */ export declare const addFinalizer: (self: Scope, finalizer: Effect.Effect) => Effect.Effect; /** * A simplified version of `addFinalizerWith` when the `finalizer` does not * depend on the `Exit` value that the scope is closed with. * * @since 1.0.0 * @category utils */ export declare const addFinalizerExit: (self: Scope, finalizer: Scope.Finalizer) => Effect.Effect; /** * Closes a scope with the specified exit value, running all finalizers that * have been added to the scope. * * @since 1.0.0 * @category destructors */ export declare const close: (self: CloseableScope, exit: Exit.Exit) => Effect.Effect; /** * Extends the scope of an `Effect` workflow that needs a scope into this * scope by providing it to the workflow but not closing the scope when the * workflow completes execution. This allows extending a scoped value into a * larger scope. * * @since 1.0.0 * @category utils */ export declare const extend: { (scope: Scope): (effect: Effect.Effect) => Effect.Effect, E, A>; (effect: Effect.Effect, scope: Scope): Effect.Effect, E, A>; }; /** * Forks a new scope that is a child of this scope. The child scope will * automatically be closed when this scope is closed. * * @since 1.0.0 * @category utils */ export declare const fork: (self: Scope, strategy: ExecutionStrategy.ExecutionStrategy) => Effect.Effect; /** * Uses the scope by providing it to an `Effect` workflow that needs a scope, * guaranteeing that the scope is closed with the result of that workflow as * soon as the workflow completes execution, whether by success, failure, or * interruption. * * @since 1.0.0 * @category destructors */ export declare const use: { (scope: CloseableScope): (effect: Effect.Effect) => Effect.Effect, E, A>; (effect: Effect.Effect, scope: CloseableScope): Effect.Effect, E, A>; }; /** * Creates a Scope where Finalizers will run according to the `ExecutionStrategy`. * * If an ExecutionStrategy is not provided `sequential` will be used. * * @since 1.0.0 * @category constructors */ export declare const make: (executionStrategy?: ExecutionStrategy.ExecutionStrategy) => Effect.Effect; //# sourceMappingURL=Scope.d.ts.map