Effect CommunityEC
Effect Community10mo ago
9 replies
spaethnl

Ergonomic Way to Filter Errors in `Result` with `@effect-rx/rx-react`

Is this the most ergonomic way of filtering an error from Result in @effect-rx/rx-react, or is there a better pattern for this kind of task?

  const thingRx = useRxSuspense(getThingRx(thingId))
  if (!thingRx.waiting && Result.isFailure(thingRx)) {
    if (Cause.isFailType(thingRx.cause) && (Cause.isNoSuchElementException(thingRx.cause.error)) {
      return <ThingNotFound id={thingId} />
    }
    else return <SomeUnexpectedErrorComponent />
  }
Was this page helpful?