Effect CommunityEC
Effect Community8mo ago
2 replies
gavriguy

Ignore all failures in when using Effect.all

I want to run Effect.all and ignore all failures.
I came up with the following but I wonder if there is a better alternative:


import { Effect, Either } from "effect"

const e1 = Effect.succeed("e1")
const e2 = Effect.fail("e2")
const e3 = Effect.succeed("e3")

Effect.all([e1, e2, e3], {
  mode: "either",
}).pipe(
  Effect.map((arr) => arr.filter(Either.isRight).map((x) => Either.isRight(x) ? x.right : null)),
  Effect.runPromise
).then(console.log)

https://effect.website/play/#3711f2908435
Effect Documentation
Was this page helpful?