@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
md 32 lines 574 Bytes
Rendered Raw
1 # Generators
2
3 ## `Effect.gen`: Passing `this`
4
5 In v3, you could pass a `self` value directly as the first argument to
6 `Effect.gen`. In v4, `self` must be wrapped in an options object.
7
8 **v3**
9
10 ```ts
11 import { Effect } from "effect"
12
13 class MyService {
14 readonly local = 1
15 compute = Effect.gen(this, function*() {
16 return yield* Effect.succeed(this.local + 1)
17 })
18 }
19 ```
20
21 **v4**
22
23 ```ts
24 import { Effect } from "effect"
25
26 class MyService {
27 readonly local = 1
28 compute = Effect.gen({ self: this }, function*() {
29 return yield* Effect.succeed(this.local + 1)
30 })
31 }
32 ```