Scope overview
Added in v2.0.0
Table of contents
constructors
make
Creates a Scope where Finalizers will run according to the ExecutionStrategy
.
If an ExecutionStrategy is not provided sequential
will be used.
Signature
export declare const make: (executionStrategy?: ExecutionStrategy.ExecutionStrategy) => Effect.Effect<CloseableScope>
Added in v2.0.0
context
Scope
Signature
export declare const Scope: Context.Tag<Scope, Scope>
Added in v2.0.0
destructors
close
Closes a scope with the specified exit value, running all finalizers that have been added to the scope.
Signature
export declare const close: (self: CloseableScope, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>
Added in v2.0.0
use
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.
Signature
export declare const use: {
(scope: CloseableScope): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Scope>>
<A, E, R>(effect: Effect.Effect<A, E, R>, scope: CloseableScope): Effect.Effect<A, E, Exclude<R, Scope>>
}
Added in v2.0.0
models
CloseableScope (interface)
Signature
export interface CloseableScope extends Scope, Pipeable {
readonly [CloseableScopeTypeId]: CloseableScopeTypeId
/**
* @internal
*/
close(exit: Exit.Exit<unknown, unknown>): Effect.Effect<void>
}
Added in v2.0.0
Scope (interface)
Signature
export interface Scope extends Pipeable {
readonly [ScopeTypeId]: ScopeTypeId
readonly strategy: ExecutionStrategy.ExecutionStrategy
/**
* @internal
*/
fork(strategy: ExecutionStrategy.ExecutionStrategy): Effect.Effect<Scope.Closeable>
/**
* @internal
*/
addFinalizer(finalizer: Scope.Finalizer): Effect.Effect<void>
}
Added in v2.0.0
symbols
CloseableScopeTypeId
Signature
export declare const CloseableScopeTypeId: typeof CloseableScopeTypeId
Added in v2.0.0
CloseableScopeTypeId (type alias)
Signature
export type CloseableScopeTypeId = typeof CloseableScopeTypeId
Added in v2.0.0
ScopeTypeId
Signature
export declare const ScopeTypeId: typeof ScopeTypeId
Added in v2.0.0
ScopeTypeId (type alias)
Signature
export type ScopeTypeId = typeof ScopeTypeId
Added in v2.0.0
utils
Scope (namespace)
Added in v2.0.0
Closeable (type alias)
Signature
export type Closeable = CloseableScope
Added in v2.0.0
Finalizer (type alias)
Signature
export type Finalizer = (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>
Added in v2.0.0
addFinalizer
Adds a finalizer to this scope. The finalizer is guaranteed to be run when the scope is closed.
Signature
export declare const addFinalizer: (self: Scope, finalizer: Effect.Effect<unknown>) => Effect.Effect<void>
Added in v2.0.0
addFinalizerExit
A simplified version of addFinalizerWith
when the finalizer
does not depend on the Exit
value that the scope is closed with.
Signature
export declare const addFinalizerExit: (self: Scope, finalizer: Scope.Finalizer) => Effect.Effect<void>
Added in v2.0.0
extend
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.
Signature
export declare const extend: {
(scope: Scope): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Scope>>
<A, E, R>(effect: Effect.Effect<A, E, R>, scope: Scope): Effect.Effect<A, E, Exclude<R, Scope>>
}
Added in v2.0.0
fork
Forks a new scope that is a child of this scope. The child scope will automatically be closed when this scope is closed.
Signature
export declare const fork: (self: Scope, strategy: ExecutionStrategy.ExecutionStrategy) => Effect.Effect<CloseableScope>
Added in v2.0.0