mirror of
https://github.com/ReactiveX/RxSwift.git
synced 2024-10-04 22:17:41 +03:00
infallible public
This commit is contained in:
parent
2ff7b9ff40
commit
e85180a704
@ -6,15 +6,29 @@
|
||||
// Copyright © 2020 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
extension ObservableConvertibleType {
|
||||
public extension ObservableConvertibleType {
|
||||
/// Convert to an `Infallible`
|
||||
///
|
||||
/// - returns: `Infallible<Element>`
|
||||
func asInfallible(onErrorJustReturn element: Element) -> Infallible<Element> {
|
||||
Infallible(self.asObservable().catchAndReturn(element))
|
||||
}
|
||||
|
||||
/// Convert to an `Infallible`
|
||||
///
|
||||
/// - parameter onErroFallbackTo: Fall back to this provided infallible on error
|
||||
///
|
||||
///
|
||||
/// - returns: `Infallible<Element>`
|
||||
func asInfallible(onErrorFallbackTo infallible: Infallible<Element>) -> Infallible<Element> {
|
||||
Infallible(self.asObservable().catch { _ in infallible.asObservable() })
|
||||
}
|
||||
|
||||
/// Convert to an `Infallible`
|
||||
///
|
||||
/// - parameter onErrorRecover: Recover with the this infallible closure
|
||||
///
|
||||
/// - returns: `Infallible<Element>`
|
||||
func asInfallible(onErrorRecover: @escaping (Swift.Error) -> Infallible<Element>) -> Infallible<Element> {
|
||||
Infallible(asObservable().catch { onErrorRecover($0).asObservable() })
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user