Skip to content

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

Merged
merged 2 commits into from
Apr 19, 2017
Merged

Conversation

twz123
Copy link
Contributor

@twz123 twz123 commented Apr 18, 2017

  • 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")
Copy link
Contributor

@slandelle slandelle left a 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks unused to me

Copy link
Contributor Author

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);

Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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());
Copy link
Contributor

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.

@twz123
Copy link
Contributor Author

twz123 commented Apr 18, 2017

Done. I opted to do lazy init for the cached DisposedException in order to capture at least one meaningful StackTraceElement.

@slandelle slandelle merged commit 43b20af into AsyncHttpClient:master Apr 19, 2017
@slandelle
Copy link
Contributor

Great work, thanks a lot!

@slandelle slandelle added this to the 2.1.0 milestone Apr 19, 2017
@twz123 twz123 deleted the rxjava2 branch April 20, 2017 07:09
twz123 added a commit to twz123/async-http-client that referenced this pull request Apr 20, 2017
* 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")
twz123 added a commit to twz123/async-http-client that referenced this pull request Apr 20, 2017
* 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")
slandelle pushed a commit that referenced this pull request Apr 20, 2017
* 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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants