Closed Woollim closed 4 years ago
Warnings | |
---|---|
:warning: | It looks like code was changed without adding anything to the Changelog. If this is a trivial PR that doesn't need a changelog, add #trivial to the PR title or body. |
Generated by :no_entry_sign: dangerJS
Hello đź‘‹
I want to add
mapToResult
operatormapToResult
operator is transform Observable’s event (Element
,Error
) to element ofResult<Element, Error>
If we useResult
as Observable’sElement
, we can solve two problems.Problem 1 The type of error emitted by Observable is Swift.Error. Therefore, we add unnecessary error statements. ex)
case default
Solution 1
Result
can specify that Observable only emits certain error type. So we don’t have to add unnecessary error statements.Problem 1 When emitted error by Observable, that was died (even HotObservable)
Solution 2 If Observable emit
Result.failure
instead of error, we can deal with errors without completion of Observable.Many Library use
Result
(Alamofire, Maya, Combine…), so I’m suremapToResult
Operator will be very useful in RxSwift. Give me your useful opinion, Thanks you.