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

combineLatest(Iterable<Publisher<>>, Function<>) not emitting on empty iterable #5412

Closed
Sroka opened this issue Jun 14, 2017 · 3 comments · Fixed by #5413
Closed

combineLatest(Iterable<Publisher<>>, Function<>) not emitting on empty iterable #5412

Sroka opened this issue Jun 14, 2017 · 3 comments · Fixed by #5413
Labels

Comments

@Sroka
Copy link
Contributor

Sroka commented Jun 14, 2017

I am using RxJava 2.10 and operator

io.reactivex.Flowable#combineLatest(java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends T>>, io.reactivex.functions.Function<? super java.lang.Object[],? extends R>)

but I've seen this behavior in 1.x as well.

Overload of combineLatests (and combineLatestsDelayError) that takes Iterable of Publishers is not emitting any items and 'combiner' function passed to it is not called when iterable is empty. For this operator I would expect it to scale linearly, that is:

  • If I pass Iterable of size 2 as a first argument I expect an Array of size 2 to be passed to combiner function
  • If I pass Iterable of size 1 as a first argument I expect an Array of size 1 to be passed to combiner function
  • If I pass Iterable of size 0 as a first argument I expect an Array of size 0 to be passed to combiner function
@akarnokd
Copy link
Member

Wrong expectation. If you know you have zero sources, you are using the wrong operator to trigger actions. You can pick just, map it and actually ignore the input value. If you don't know you have zero sources, you still have the option to switch to a non-empty source via switchIfEmpty.

@Sroka
Copy link
Contributor Author

Sroka commented Jun 14, 2017

@akarnokd Well, OK, makes sense. It took me quite a while to track this one down. Do you think it should be included in the docs? I can document it and make pull request

@akarnokd
Copy link
Member

Yes, something along the line of this:

Providing an empty array/Iterable will result in an immediate completion without any calls to the provided combiner function.

Note that there are several overloads to be considered in both Flowable and Observable.

Sroka added a commit to Sroka/RxJava that referenced this issue Jun 14, 2017
…accepting unspecified number of sources. This commit resolves ReactiveX#5412
Sroka added a commit to Sroka/RxJava that referenced this issue Jun 23, 2017
…accepting unspecified number of sources. This commit resolves ReactiveX#5412
Sroka added a commit to Sroka/RxJava that referenced this issue Jun 23, 2017
…accepting unspecified number of sources. This commit resolves ReactiveX#5412
akarnokd pushed a commit that referenced this issue Jun 28, 2017
…accepting unspecified number of sources. This commit resolves #5412 (#5413)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants