Search in sources :

Example 1 with RepoCommentAddedSubscription

use of com.apollographql.apollo.sample.RepoCommentAddedSubscription in project apollo-android by apollographql.

the class GitHuntEntryDetailActivity method subscribeRepoCommentAdded.

private void subscribeRepoCommentAdded() {
    ApolloSubscriptionCall<RepoCommentAddedSubscription.Data> subscriptionCall = application.apolloClient().subscribe(new RepoCommentAddedSubscription(repoFullName));
    disposables.add(Rx2Apollo.from(subscriptionCall).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<Response<RepoCommentAddedSubscription.Data>>() {

        @Override
        public void onNext(Response<RepoCommentAddedSubscription.Data> response) {
            commentsListViewAdapter.addItem(response.data().commentAdded().content());
        }

        @Override
        public void onError(Throwable e) {
            Log.e(TAG, e.getMessage(), e);
        }

        @Override
        public void onComplete() {
            Log.d(TAG, "Subscription exhausted");
        }
    }));
}
Also used : Response(com.apollographql.apollo.api.Response) RepoCommentAddedSubscription(com.apollographql.apollo.sample.RepoCommentAddedSubscription) DisposableSubscriber(io.reactivex.subscribers.DisposableSubscriber)

Aggregations

Response (com.apollographql.apollo.api.Response)1 RepoCommentAddedSubscription (com.apollographql.apollo.sample.RepoCommentAddedSubscription)1 DisposableSubscriber (io.reactivex.subscribers.DisposableSubscriber)1