Merge commit '36c66dd290d3ce6eb1ccd310d0c658d4a32bb8eb' as 'repos/effect'
This commit is contained in:
32
repos/effect/migration/generators.md
Normal file
32
repos/effect/migration/generators.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Generators
|
||||
|
||||
## `Effect.gen`: Passing `this`
|
||||
|
||||
In v3, you could pass a `self` value directly as the first argument to
|
||||
`Effect.gen`. In v4, `self` must be wrapped in an options object.
|
||||
|
||||
**v3**
|
||||
|
||||
```ts
|
||||
import { Effect } from "effect"
|
||||
|
||||
class MyService {
|
||||
readonly local = 1
|
||||
compute = Effect.gen(this, function*() {
|
||||
return yield* Effect.succeed(this.local + 1)
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
**v4**
|
||||
|
||||
```ts
|
||||
import { Effect } from "effect"
|
||||
|
||||
class MyService {
|
||||
readonly local = 1
|
||||
compute = Effect.gen({ self: this }, function*() {
|
||||
return yield* Effect.succeed(this.local + 1)
|
||||
})
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user