I have two Observables of the same type that I want to merge into one observable and remove duplicates.
By now I tried basically all rxjs operators but none of them do what I need. See the attached picture: a lot of the rxjs operators change the type of the resulting observable.
const a: Observable<Foo[]> = ...
const b: Observable<Foo[]> = ...
These are my two calls to retrieve some data.
Now the two operations that came the closest:
combineLatest(a, b);
This one makes a new array with two indexes and the results of a will go in index 0 and results of b will go into index 1. I cant use it like this.
const c = a.pipe(mergeMap(a1 => b.pipe(map(a2 => [...a1, ...a2]))));
This one nearly got it. The problem here is following: Lets assume a return 2 results (example value: 1 and 2) and b return also 2 results (example value: 2 and 3). So the "2" is a duplicate, which should not appear twice in the resulting observable.
Does anyone know a combination of the operators so I can combine both observables and remove the duplicates?