Skip to content
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

RxJava1 bindings #341

Merged
merged 6 commits into from
Mar 23, 2017
Merged

RxJava1 bindings #341

merged 6 commits into from
Mar 23, 2017

Conversation

digitalbuddha
Copy link
Contributor

I wanted to gather thoughts on how the Rx stuff should work. Here's an attempt at doing wrappers for ApolloWatcher &ApolloCall. Similar to Retrofit we will cancel a request when the Observable is unsubscribed from.

@BenSchwab
Copy link
Contributor

This looks like a good approach to me 👍

@@ -36,6 +36,7 @@ dependencies {
compile dep.supportAnnotations
compile dep.okHttp
compile dep.moshi
compile dep.rxjava
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it be in separate module?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup! will move to module next, wanted to get feedback on api being ok

Copy link
Contributor

Choose a reason for hiding this comment

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

should be removed

@@ -0,0 +1,74 @@
package com.apollographql.android.impl;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this class must be in :apollo-rxsupport

}


public static <T> Observable<T> from(final ApolloCall<T> call) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Single?

return;
}
if (!subscriber.isUnsubscribed()) {
subscriber.onCompleted();
Copy link
Contributor

Choose a reason for hiding this comment

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

is onError not enough? I thought you must call onError or onCompleted but not both

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied from retrofit, its returning from catch block so it will on complete if no exception

}

public static <T> Single<T> from(final ApolloCall<T> call) {
return Single.create(new Single.OnSubscribe<T>() {
Copy link
Contributor

@sav007 sav007 Mar 22, 2017

Choose a reason for hiding this comment

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

if you change it to Single.fromCallable then you don't need try/catch

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh you need access to subscriber

import rx.functions.Action0;
import rx.subscriptions.Subscriptions;

public class RxApollo {
Copy link
Contributor

Choose a reason for hiding this comment

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

final, with private constructor?

@digitalbuddha
Copy link
Contributor Author

so fyi rx-support module needs to be android library since it needs ApolloClient which lives in android library runtime

@digitalbuddha
Copy link
Contributor Author

closes #243

}
}

apply plugin: 'com.android.library'
Copy link
Contributor

Choose a reason for hiding this comment

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

you think it should be android lib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it depends on Runtime which is currently an android lib. If/when we move sql stuff out to its own module we can change this to java

@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=rx
POM_NAME=ApolloStack Runtime
Copy link
Contributor

Choose a reason for hiding this comment

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

RxSupport

@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=rx
Copy link
Contributor

Choose a reason for hiding this comment

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

rxsupport?

@@ -10,7 +10,8 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface ApolloCall<T> {

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove line

compile dep.moshi
compile dep.rxjava
compile project(":apollo-runtime")
compile project(":apollo-api")
Copy link
Contributor

@marwanad marwanad Mar 23, 2017

Choose a reason for hiding this comment

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

both of those should be provided because rx-support should assume those would be available at runtime

(Also, compile project(":apollo-runtime") doesn't bring the transitive compile project deps with it. That's why having compile project(":apollo-api") under runtime, still required you to bring that in.

@@ -26,8 +26,9 @@ android {
}

dependencies {
provided project(':apollo-api')
compile project(':apollo-api')
Copy link
Contributor

Choose a reason for hiding this comment

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

can be provided because otherwise it would cause dex errors when the plugin is added.

dependencies {
compile dep.jsr305
compile dep.supportAnnotations
compile dep.okHttp
Copy link
Contributor

@marwanad marwanad Mar 23, 2017

Choose a reason for hiding this comment

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

ditto all those apart from Rx should be provided since runtime would bring those already.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, I don't think you'd need to include any of those. apart from Rx.

@digitalbuddha digitalbuddha changed the title first stab rxjava RxJava1 bindings Mar 23, 2017
@digitalbuddha digitalbuddha merged commit ac204f2 into master Mar 23, 2017
@marwanad marwanad deleted the feature/rx1 branch March 26, 2017 15:33
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.

4 participants