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

Flowable.fromIterable does not work as expected when used in switchMap #6615

Closed
adrian-linca opened this issue Aug 14, 2019 · 2 comments · Fixed by #6616
Closed

Flowable.fromIterable does not work as expected when used in switchMap #6615

adrian-linca opened this issue Aug 14, 2019 · 2 comments · Fixed by #6616
Milestone

Comments

@adrian-linca
Copy link

adrian-linca commented Aug 14, 2019

This issue was reproduces on RX-Java v2.2.6 and v3.0.0-RC1

I have this piece of code:

Flowable
  .range(1, 2)
  .doOnNext(value -> {
    System.out.println("value1: " + value);
  })
  .switchMap(value -> Flowable.just(value * 10))
  .subscribe(
    value -> System.out.println("value2: " + value),
    throwable -> System.out.println("error: " + throwable),
    () -> System.out.println("complete")
   );

When run it prints:
value1: 1
value2: 10
value1: 2
value2: 20
complete

Then I have the exact same thing but with Flowable.fromIterable:

Flowable
    .range(1, 2)
    .doOnNext(value -> {
        System.out.println("value1: " + value);
    })
    .switchMap(value -> Flowable.fromIterable(Arrays.asList(value * 10)))
    .subscribe(
        value -> System.out.println("value2: " + value),
        throwable -> System.out.println("error: " + throwable),
        () -> System.out.println("complete")
    );

This one prints:
value1: 1
value2: 10

And then nothing, no complete, no error, nothing.

@akarnokd akarnokd added this to the 3.0 milestone Aug 14, 2019
@akarnokd
Copy link
Member

Hi and thanks for reporting. This is a bug in switchMap not playing nice with fromIterable. You can work around by applying .hide() to fromIterable. I'll post a fix shortly.

@adrian-linca
Copy link
Author

Thanks.

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

Successfully merging a pull request may close this issue.

2 participants