japgolly/scalajs-react

Provide default IO/SyncIO error handler for component

matthughes opened this issue · 0 comments

Maybe this is already possible but I'd love to be able to have a default error handler for any IO/SyncIO/Callback effect. Something like:

    ScalaComponent
      .builder[Props]("MyComponent")
      .initialState(State.Initial)
      .renderBackend[Backend]
      .onError(s => s.backend.handleError(s.error))

This would be akin to adding.onError to every effect you submit (onClick/componentDidMethods). I have to believe there is a way to do this with the Dispatch/Effect classes but can't quite figure it out. Would be great to have a more ergonomic way though. If someone could generally point my in a direction I can try to submit a PR.