Skip to content
Source
Sign inSign up

scope.md

50 lines1.1 KB

1# Scope
2​
3## `Scope.extend` → `Scope.provide`
4​
5`Scope.extend` has been renamed to `Scope.provide` in v4. The behavior is
6identical: it provides a `Scope` to an effect that requires one, removing
7`Scope` from the effect's requirements without closing the scope when the
8effect completes.
9​
10The new name better reflects the operation — you are providing a service (the
11`Scope`) to an effect, consistent with how other services are provided in
12Effect.
13​
14**v3**
15​
16```ts
17import { Effect, Scope } from "effect"
18​
19const program = Effect.gen(function*() {
20 const scope = yield* Scope.make()
21 yield* Scope.extend(myEffect, scope)
22})
23```
24​
25**v4**
26​
27```ts
28import { Effect, Scope } from "effect"
29​
30const program = Effect.gen(function*() {
31 const scope = yield* Scope.make()
32 yield* Scope.provide(scope)(myEffect)
33})
34```
35​
36Both data-first and data-last (curried) forms are supported:
37​
38```ts
39// data-first
40Scope.provide(myEffect, scope)
41​
42// data-last (curried)
43myEffect.pipe(Scope.provide(scope))
44```
45​
46## Quick Reference
47​
48| v3 | v4 |
49| -------------- | --------------- |
50| `Scope.extend` | `Scope.provide` |