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