Hyperlinkv0.8.0-beta.28

Scope

Scope.useconsteffect/Scope.ts:569
(scope: Closeable): <A, E, R>(
  self: Effect<A, E, R>
) => Effect<A, E, Exclude<R, Scope>>
<A, E, R>(self: Effect<A, E, R>, scope: Closeable): Effect<
  A,
  E,
  Exclude<R, Scope>
>

Runs an effect with the provided closeable scope in its context and closes that scope when the effect exits.

When to use

Use when you already have a Closeable scope and want to run an effect that requires Scope while automatically closing that scope when the effect exits.

Details

The scope is closed with the same exit value as the effect, so registered finalizers can observe whether the effect succeeded, failed, or was interrupted.

combinators
Source effect/Scope.ts:5694 lines
export const use: {
  (scope: Closeable): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, Scope>>
  <A, E, R>(self: Effect<A, E, R>, scope: Closeable): Effect<A, E, Exclude<R, Scope>>
} = effect.scopeUse