Adds catch variant.

This commit is contained in:
Krunoslav Zaher 2015-05-02 18:09:04 +02:00
parent 62a5acbf65
commit 172a6a68f8
1 changed files with 10 additions and 1 deletions

View File

@ -61,8 +61,17 @@ public func catch<E>
}
}
// In case of error, terminates sequence with `replaceErrorWith`.
public func catch<E>
(replaceErrorWith: E)
-> (Observable<E> -> Observable<E>) {
return { source in
return Catch(source: source, handler: { _ in success(returnElement(replaceErrorWith)) })
}
}
// When error happens `error` will be forwarded as a next `Result<E>` value
// and sequence will be completed
// and sequence will be completed.
public func catchToResult<E>
(source: Observable<E>)
-> Observable<Result<E>> {