Merge commit '36c66dd290d3ce6eb1ccd310d0c658d4a32bb8eb' as 'repos/effect'
This commit is contained in:
50
repos/effect/migration/scope.md
Normal file
50
repos/effect/migration/scope.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Scope
|
||||
|
||||
## `Scope.extend` → `Scope.provide`
|
||||
|
||||
`Scope.extend` has been renamed to `Scope.provide` in v4. The behavior is
|
||||
identical: it provides a `Scope` to an effect that requires one, removing
|
||||
`Scope` from the effect's requirements without closing the scope when the
|
||||
effect completes.
|
||||
|
||||
The new name better reflects the operation — you are providing a service (the
|
||||
`Scope`) to an effect, consistent with how other services are provided in
|
||||
Effect.
|
||||
|
||||
**v3**
|
||||
|
||||
```ts
|
||||
import { Effect, Scope } from "effect"
|
||||
|
||||
const program = Effect.gen(function*() {
|
||||
const scope = yield* Scope.make()
|
||||
yield* Scope.extend(myEffect, scope)
|
||||
})
|
||||
```
|
||||
|
||||
**v4**
|
||||
|
||||
```ts
|
||||
import { Effect, Scope } from "effect"
|
||||
|
||||
const program = Effect.gen(function*() {
|
||||
const scope = yield* Scope.make()
|
||||
yield* Scope.provide(scope)(myEffect)
|
||||
})
|
||||
```
|
||||
|
||||
Both data-first and data-last (curried) forms are supported:
|
||||
|
||||
```ts
|
||||
// data-first
|
||||
Scope.provide(myEffect, scope)
|
||||
|
||||
// data-last (curried)
|
||||
myEffect.pipe(Scope.provide(scope))
|
||||
```
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| v3 | v4 |
|
||||
| -------------- | --------------- |
|
||||
| `Scope.extend` | `Scope.provide` |
|
||||
Reference in New Issue
Block a user