AsyncExtensions icon indicating copy to clipboard operation
AsyncExtensions copied to clipboard

opeators: add a MapError opeator

Open JCSooHwanCho opened this issue 3 years ago • 3 comments
trafficstars

Description

This PR adds MapError Operator, which is transforms error upstream emits

Checklist

  • [ ] this PR is based on the main branch and is up-to-date, if not please rebase your branch on the top of main
  • [ ] the commits inside this PR have explicit commit messages
  • [ ] unit tests cover the new feature or the bug fix
  • [ ] the feature is documented in the README.md if it makes sense
  • [ ] the CHANGELOG is up-to-date

JCSooHwanCho avatar Mar 24 '22 05:03 JCSooHwanCho

Hi @JCSooHwanCho

Thanks for this PR.

Mmmmh, I'm not sure if this is useful to be able to map the error since an AsyncSequence, unlike a Combine publisher, is not parametrised by a Failure type.

In the end we still have to handle all kinds of Errors in the catch section. The mapError does not bring type safety here.

Do you see a big advantage to that ?

twittemb avatar Mar 30 '22 16:03 twittemb

@twittemb I needed some functionality that catch some error and change it to another Error. so first I thought was mapError operator in Combine, implement and use it. but by your comment, catch operator in RxSwift is rather nicer than mapError with AsyncSequence case.

JCSooHwanCho avatar Apr 10 '22 12:04 JCSooHwanCho

@JCSooHwanCho I have introduced a .mapToResult operator (main branch), it might be more versatile

twittemb avatar Sep 26 '22 08:09 twittemb