These are chat archives for ReactiveX/RxJava

Jun 2016
Jun 12 2016 15:26
Hello, I have a question, do I need to check observable's terminal/intermediate operation like Java 8's Stream API?
Jun 12 2016 15:27
All operators are Intermediate in Rx. Except Subscribe.
I'm not even sure if we call Subscribe an operator.
Jun 12 2016 15:29
oh thanks you
The Javadoc of Observable's subscribe method said that: "Subscribes to an Observable and provides a callback to handle the items it emits."
It makes me confused alot because I don't understand where are observers??
Kartikay Dani
Jun 12 2016 15:41

Hi all, I have this small question regarding rx

I have this simple retrofit2 api interface which contains

    interface Api {
        @GET(BuildConfig.END_POINT) Observable<Response> fetchData();

So everything is fine when I'm doing a fresh request but let say I fire a request and I un-subscribe immediately or if the request is fired in the background (and no one is there to listen) and then I try to fire new request it returns nothing.

So, in code it looks something like this:

in Activity::onPause I perform un-subscription and in Activity::onResume I fire the request again.

My request looks something like this::

        .doOnNext(new Action1<Response>() {
            @Override public void call(Response response) {
                list = response.getDataForList();
        }).flatMap(new Func1<Response, Observable<List<Object>>>() {
            @Override public Observable<Object>> call(Response response) {
                return Observable.just(list);

When I tried debugging it, the call is made but doOnNext() is not called. None of the lifecycle methods are called.

And just for clarification from here I'm just returning the observable which I'm using it somewhere else where I'm observing on main thread and subscribing on IO.

I don't know if I doing something wrong in rx or if it's a retrofit issue. Any help or suggestions will be appreciated. Thanks for your time 👍

Jun 12 2016 15:51
@dangxunb The callbacks in the Subscribe method make up the observer.
you could see it as Observable.subscribe(observer) and observer {onNext: { ... }, onCompleted {...}, onError {...}}, so you call Observable.subscribe((next) -> {...}, (error) -> {...}, () -> { ... completed ...} )
Jun 12 2016 15:53
very clear, thanks you so much!
Jun 12 2016 20:14
Does BehaviorSubject internally use a computational scheduler?
Ben Christensen
Jun 12 2016 20:17
Subjects have no scheduling.
Jun 12 2016 20:19
I checked it by print the name of the Thread in the subscription's callback block. It said: RxComputationScheduler-1. I don't specify any subscribeOn() Scheduler
Oh excuse me, my fault. I missed the sample() operation. Very sorry :worried: