-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Introduce AHC RxJava 2.x extras #1391
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
Conversation
* Main interface is RxHttpClient modelled after AsyncHttpSingle from RxJava 1.x extras * Use Maybe reactive base type instead of Single, since RxJava 2 won't allow emission of null values any longer * Update to RxJava/ReactiveStreams terminology (i.e. "unsubscribe" became "dispose")
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.
Thanks! Could you please address comments?
public DisposedException() { | ||
} | ||
|
||
public DisposedException(final Throwable cause) { |
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.
looks unused to me
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.
Yep, just like in the RxJava1 extras. It's just a convenience thingy when someone wants to use/extend this stuff. I'll remove it if you prefer...?
* if at least one of the parameters is {@code null} | ||
*/ | ||
<T> Maybe<T> prepare(Request request, Supplier<? extends AsyncHandler<T>> handlerSupplier); | ||
|
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.
nit: kill empty line
final T result; | ||
try { | ||
result = delegate().onCompleted(); | ||
} catch (final Throwable 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.
Is it really OK to catch Throwable instead of only Exception?
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.
That's an RxJava pattern found in various places there, e.g. in one of the the map operator implementations. If it's some "fatal" exception from RxJava's point of view, it will be rethrown via io.reactivex.exceptions.Exceptions.throwIfFatal(…)
in emitOnError
. Everything else will be reported via onError
.
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.
Good to know, thanks
*/ | ||
protected final AsyncHandler.State disposed() { | ||
if (!delegateTerminated.getAndSet(true)) { | ||
delegate().onThrowable(new DisposedException()); |
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.
DisposedException
could be turned into a singleton/constant without stacktrace.
Done. I opted to do lazy init for the cached |
Great work, thanks a lot! |
* Main interface is RxHttpClient modelled after AsyncHttpSingle from RxJava 1.x extras * Use Maybe reactive base type instead of Single, since RxJava 2 won't allow emission of null values any longer * Update to RxJava/ReactiveStreams terminology (i.e. "unsubscribe" became "dispose")
* Main interface is RxHttpClient modelled after AsyncHttpSingle from RxJava 1.x extras * Use Maybe reactive base type instead of Single, since RxJava 2 won't allow emission of null values any longer * Update to RxJava/ReactiveStreams terminology (i.e. "unsubscribe" became "dispose")
* Main interface is RxHttpClient modelled after AsyncHttpSingle from RxJava 1.x extras * Use Maybe reactive base type instead of Single, since RxJava 2 won't allow emission of null values any longer * Update to RxJava/ReactiveStreams terminology (i.e. "unsubscribe" became "dispose")
RxHttpClient
, modelled afterAsyncHttpSingle
from RxJava 1.x extrasMaybe
reactive base type instead ofSingle
, since RxJava 2 won't allow emission ofnull
values any longer