-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flatmap Single into Observable and ignore errors #3472
Comments
Generally, this is why I'm skeptic about |
My current solution wraps my Singles: public static <T> Observable<T> onErrorResumeNext(final Single<T> single,
final Observable<? extends T> resumeSequence) {
return single.toObservable().onErrorResumeNext(resumeSequence);
}
public static <T> Observable<T> onErrorResumeNext(final Single<T> single,
final Func1<Throwable, ? extends Observable<? extends T>> resumeFunction) {
return single.toObservable().onErrorResumeNext(resumeFunction);
} RxView.clicks(myButton)
.flatMap(v - > onErrorResumeNext(networkRequest(),
throwable -> {
// somehow handle error here
return Observable.empty();
}))
.subscribe(data -> showSomething(data),
e -> {
// only called when the RxView.clicks() throws
}); @benjchristensen what happened to the initial idea of heaving a
I was hoping a |
@artem-zinnatullin I'm starting to loose what is implemented where. Do you work on |
@akarnokd damn… will submit PR today/tomorrow! |
My solution: |
I have UI observable which should work as long as my UI lives. When my UI emits I create a network request which could be an Observable or a Single. A Single fits best for a network call.
When using an Observable I would use
onErrorResumeNext
returningObservable.empty()
to prevent errors coming from the network request going into my UI Observable and callingonError
because the UI Observable should life forever:This, in my opinion, elegant way does not work for Single because no
Single.empty()
exists.Single.onErrorResumeNext
is btw only available in 2.xConverting my
Single
to anObservable
seems wrong, because the network request is aSingle
!The text was updated successfully, but these errors were encountered: