Rxjava: ReplaySubject and PublisherSubject Bug

Created on 5 Jul 2017  路  4Comments  路  Source: ReactiveX/RxJava

I'm use rxjava version 2.1.1.
I think I found a litle bug

Every time I send object to a observers, the my subscribe never is called when I'm use flatMapInterable and toList to processe itens in my list before him.
the subscribes only called when subject.onComplete() isso called.
Please see the code.

ReplaySubject<List<Object>> subject = ReplaySubject.create();
subject.flatMapIterable(object -> {
            Log.d(TAG, "flatMapIterable: it is called " + object.toString());
            return object;
        }).doOnEach(objNotification -> Log.d(TAG, "doOnEach: it is called " + objNotification.getValue().toString()))
          .toList()
          .subscribe(obj -> Log.d(TAG, "subscribe: it is only called after subscribe.onComplete()" + obj.toString()));
subject.onNext(getListOfObjects());
Log.d(TAG, "onComplete:");
subject.onComplete();

See the logcat

07-04 23:20:38.258 10770-10770/app.package D/TAG: flatMapIterable: it is called
07-04 23:20:38.259 10770-10770/app.package D/TAG: doOnEach: it is called
07-04 23:20:38.259 10770-10770/app.package D/TAG: onComplete:
07-04 23:20:38.260 10770-10770/app.package D/TAG: doOnEach: it is called
07-04 23:20:38.260 10770-10770/app.package D/TAG: it is only called after subscribe.onComplete()

P.S. Sorry my bad english

2.x Question

All 4 comments

That seems (to me at least) to be working as intended, looking at the marble diagram of toList. How would toList "know" it's supposed to emit something without a terminal event?
Maybe you could use the buffer operator, it might do what you want...

The Javadoc of toList has been updated to emphasize on the finite requirement via #5465.

Hye guys thanks for helping.

You are welcome.

Was this page helpful?
0 / 5 - 0 ratings