From e85180a704027313081c0a058334839f5264c587 Mon Sep 17 00:00:00 2001 From: freak4pc Date: Sun, 4 Oct 2020 08:57:05 +0300 Subject: [PATCH] infallible public --- .../ObservableConvertibleType+Infallible.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/RxSwift/Traits/Infallible/ObservableConvertibleType+Infallible.swift b/RxSwift/Traits/Infallible/ObservableConvertibleType+Infallible.swift index b7472bc9..d54d28da 100644 --- a/RxSwift/Traits/Infallible/ObservableConvertibleType+Infallible.swift +++ b/RxSwift/Traits/Infallible/ObservableConvertibleType+Infallible.swift @@ -6,15 +6,29 @@ // Copyright © 2020 Krunoslav Zaher. All rights reserved. // -extension ObservableConvertibleType { +public extension ObservableConvertibleType { + /// Convert to an `Infallible` + /// + /// - returns: `Infallible` func asInfallible(onErrorJustReturn element: Element) -> Infallible { Infallible(self.asObservable().catchAndReturn(element)) } + /// Convert to an `Infallible` + /// + /// - parameter onErroFallbackTo: Fall back to this provided infallible on error + /// + /// + /// - returns: `Infallible` func asInfallible(onErrorFallbackTo infallible: Infallible) -> Infallible { Infallible(self.asObservable().catch { _ in infallible.asObservable() }) } + /// Convert to an `Infallible` + /// + /// - parameter onErrorRecover: Recover with the this infallible closure + /// + /// - returns: `Infallible` func asInfallible(onErrorRecover: @escaping (Swift.Error) -> Infallible) -> Infallible { Infallible(asObservable().catch { onErrorRecover($0).asObservable() }) }