EffectTalk

Effect.gen for sequential code

Effect.gen lets you write sequential Effect code like async/await. Use yield* to unwrap Effects and get their values.

In the anti-pattern, we nest callbacks. In the Effect way, we write flat, readable code.

  • Use Effect.gen(function* () { ... }) for sequential code
  • Use yield* to unwrap an Effect and get its value
  • Return the final value from the generator
Loading code editor...