【发布时间】:2021-03-09 14:20:34
【问题描述】:
我有两个不同的数据流,它们为相同的对象提供修改后的属性值。我想编写一个订阅,以便每当两个 DataStream 中的任何一个通知属性修改时,我都可以重用相同的代码。
const selectedItems$ = this.grid.onSelect.pipe(.... this gives me the selected object);
const updatedItem$ = this.fetchData.onUpdate.pipe(.....this gives me the updated object);
displayItem$(selection$, updatedItem$) {
(..here i want to get notified whenever there is change in).subscribe(item => {
this.displayLatest(item)
})
}
selectedItem$ 和 updatedItem$ 可以在修改已选择的项目时返回具有不同属性值的相同对象。
这是我第一次在 RxJs 上工作,对这部分有点困惑。我在 RxJS 运算符列表(如 concat、merge、combine)中进行了搜索,但大多数工作示例都针对不同的数据结构。还有没有其他更好的方法来实现这一点?
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/questions/41060371/…
标签: javascript angular rxjs rxjs-observables rxjs-pipeable-operators