【问题标题】:RxJs: Combine two Observables - Take all from first but not all from secondRxJs:结合两个 Observables - 从第一个获取所有但不是从第二个获取所有
【发布时间】:2018-02-20 16:35:09
【问题描述】:

假设我在 rxjs 中有两个 observables。

我想获取来自第一个元素的所有元素并将它们与第二个元素组合,但如果它不在第一个元素中,则仅从第二个元素中获取元素。

元素由 id 区分。

【问题讨论】:

标签: javascript rxjs reactive-programming


【解决方案1】:

我找到了答案,也感谢链接。

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

这将输出 [1, 2, 3, 4] 但 3 取自第一个 observable。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    相关资源
    最近更新 更多