Effect CommunityEC
Effect Community3y ago
5 replies
Emberoshi

Using `return` in `Effect.gen`

Another question, when dealing with Effect.gen should I use return ?
Example
const ... = Effect.gen(function* (_) {
  const booleanValue = someFunctionReturningABoolean()
  
  if(!booleanValue){
    // Can I return here?
    yield* _(Effect.fail("some funny error"))
    // return yield* _(Effect.fail("some funny error"))
  }

  // in this ways I knoe `booleanValue` is true here

  ...

  // and the, should I return the final effect?
  return yield* _(someEffect)
})
Was this page helpful?