【发布时间】:2021-10-13 05:26:28
【问题描述】:
假设我有如下对象的源流:
source$ = from([{ id: 1, cost: 10},{ id: 2, cost: 5},{ id: 3, cost: 3},{ id: 4, cost: 10}])
在派生的 observable 中,我想维护一个额外的属性,其中包含成本的运行总和
// Expected derived stream
{ id: 1, cost: 10, totalCost: 10}
{ id: 2, cost: 5, totalCost: 15}
{ id: 3, cost: 3, totalCost: 18}
{ id: 4, cost: 10, totalCost: 28}
用rxjs怎么实现?
【问题讨论】:
标签: javascript rxjs