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

Union of multiple observables #130

Open
ivansenic opened this issue Aug 16, 2021 · 1 comment
Open

Union of multiple observables #130

ivansenic opened this issue Aug 16, 2021 · 1 comment

Comments

@ivansenic
Copy link

Is there an operator or an easy way to generate a union of elements from different observables? Meaning that only elements that exists in all observales should be pushed downstream. Would be also great if there could be an option to define the comparator.

Meaning, I would expect:

A = [1, 2, 4, 5]
B = [2, 5, 7]
C = [0, 1, 2, 5, 7]

UNION (A, B, C) = [2, 5]

Maybe something like this exists in the RxJava itself?

@akarnokd
Copy link
Owner

No single operator but you can achieve it via combination of several:

  • collect each source into a set
  • zip these and in the handler, use set1.retainAll(set2); set1.retainAll(set3); return set1;
  • use flatMapIterable to unroll the resulting intersection set.

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

No branches or pull requests

2 participants