(
scope: Scope,
finalizerStrategy?: "sequential" | "parallel"
): Effect<Closeable>Creates a closeable child scope registered with a parent scope.
Details
Closing the parent closes the child with the same exit value, and closing the
child detaches it from the parent. The optional finalizer strategy configures
the child scope and defaults to "sequential" when omitted.
Example (Creating a child scope)
import { Console, Effect, Exit, Scope } from "effect"
const nestedScopes = Effect.gen(function*() {
const parentScope = yield* Scope.make("sequential")
// Add finalizer to parent
yield* Scope.addFinalizer(parentScope, Console.log("Parent cleanup"))
// Create child scope
const childScope = yield* Scope.fork(parentScope, "parallel")
// Add finalizer to child
yield* Scope.addFinalizer(childScope, Console.log("Child cleanup"))
// Close child first, then parent
yield* Scope.close(childScope, Exit.void)
yield* Scope.close(parentScope, Exit.void)
})export const const fork: (
scope: Scope,
finalizerStrategy?: "sequential" | "parallel"
) => Effect<Closeable>
Creates a closeable child scope registered with a parent scope.
Details
Closing the parent closes the child with the same exit value, and closing the
child detaches it from the parent. The optional finalizer strategy configures
the child scope and defaults to "sequential" when omitted.
Example (Creating a child scope)
import { Console, Effect, Exit, Scope } from "effect"
const nestedScopes = Effect.gen(function*() {
const parentScope = yield* Scope.make("sequential")
// Add finalizer to parent
yield* Scope.addFinalizer(parentScope, Console.log("Parent cleanup"))
// Create child scope
const childScope = yield* Scope.fork(parentScope, "parallel")
// Add finalizer to child
yield* Scope.addFinalizer(childScope, Console.log("Child cleanup"))
// Close child first, then parent
yield* Scope.close(childScope, Exit.void)
yield* Scope.close(parentScope, Exit.void)
})
fork: (
scope: Scope(parameter) scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope: Scope,
finalizerStrategy: "sequential" | "parallel" | undefinedfinalizerStrategy?: "sequential" | "parallel"
) => interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<Closeable> = import effecteffect.const scopeFork: (
scope: Scope.Scope,
finalizerStrategy?: "sequential" | "parallel"
) => Effect.Effect<Scope.Closeable, never, never>
scopeFork