merge
ReactiveX:
combine multiple Observables into one by merging their emissions
该操作符将多个被观察者合并起来,并能一次订阅到他们的值。
let pb1 = PublishSubject<Int>()
let pb2 = PublishSubject<Int>()
Observable<Int>.merge(pb1, pb2)
.subscribe(onNext: { p in
print(p)
})
.disposed(by: bag)
pb1.onNext(2)
pb2.onNext(1)
输出:
2
1