-
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
1.x: Add Single.onErrorResumeNext(Func) #3766
1.x: Add Single.onErrorResumeNext(Func) #3766
Conversation
import rx.functions.Func1; | ||
import rx.plugins.RxJavaPlugins; | ||
|
||
public class SingleOperatorOnErrorResumeNext<T> implements Single.OnSubscribe<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just renamed SingleOperatorOnErrorResumeNextViaSingle
to something more general and it's now works with function instead of Single
directly.
a2f5e89
to
afd6649
Compare
|
||
try { | ||
unsubscribe(); | ||
resumeFunctionInCaseOfError.call(error).subscribe(child); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd separate catching the error and subscribing to the Single outside the try-catch.
@akarnokd fixed your comments, btw, should I add |
} | ||
|
||
@Test | ||
public void onErrorResumeNextViaFunctionShouldPreventNullFunction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also check/handle if the function returns a null Single.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test, but didn't handle this specifically in the operator, test will make sure that it won't be swallowed
Yes, and copy over the experimental and since tags into the javadoc. |
afd6649
to
0495044
Compare
👍 There is this new like option but do you get a notification for them? |
No On Mon, Mar 14, 2016, 8:10 PM David Karnok [email protected] wrote:
|
@Override | ||
public void onError(Throwable error) { | ||
try { | ||
resumeFunctionInCaseOfError.call(error).subscribe(child); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove unsubscribe()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's terminal state, we don't do unsubscribe()
in onSuccess()
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If resumeFunctionInCaseOfError
returns something like Observable.never.toSingle
, we should still unsubscribe
the original one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. I just found SafeSubscriber
will do it.
👍 |
👍 |
…e-next-with-function 1.x: Add Single.onErrorResumeNext(Func)
Closes #3440, closes #3731, closes #3472 (whoa, 3 issues at a time!)