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

ReplaySubject and PublisherSubject Bug #5464

Closed
marcusedu opened this issue Jul 5, 2017 · 4 comments
Closed

ReplaySubject and PublisherSubject Bug #5464

marcusedu opened this issue Jul 5, 2017 · 4 comments

Comments

@marcusedu
Copy link

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

@cardamon
Copy link
Contributor

cardamon commented Jul 5, 2017

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...

@akarnokd
Copy link
Member

akarnokd commented Jul 5, 2017

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

@marcusedu
Copy link
Author

marcusedu commented Jul 5, 2017

Hye guys thanks for helping.

@akarnokd
Copy link
Member

You are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants