简体   繁体   中英

RxJs: Combine two Observables - Take all from first but not all from second

Lets say I have two observables in rxjs.

I want to take all elements coming from the first and combine them with the second but only take the element from the second if its not already in the first.

Elements are distinct by id.

I found the answer, also thanks to the link.

var a = Observable.of([1, 2, 3])
var b = Observable.of([3, 4])
a.concat(b).distinct().subscribe(..)

which will output [1, 2, 3, 4] but the 3 was taken from the first observable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM