我的代码中有 3 个异步管道。
<div>{{formatedData$ | async}}</div>
<div>{{totalStatusData$ | async }}</div>
<div>{{totalPercentageData$ | async}}</div>
组件.ts
服务返回的实际数据如下
[{
"name": "one",
"steps": [{
"id": 1,
"passed": 1,
"failed": 3
},
{
"id": 2,
"passed": 4,
"failed": 0
}
]
},
{
"name": "two",
"steps": [{
"id":3 ,
"passed": 10,
"failed": 3
},
{
"id": 4,
"passed": 4,
"failed": 8
}
]
}
]
this.formatedData$ = this.service.data().pipe(map(data) => {
return this.formatData1();
})
现在 this.formatedData$ 如下
[{
"name": "one",
"passed": 5,
"failed": 3
},
{
"name": "two",
"passed": 14,
"failed": 11
}
]
this.totalStatusData$=this.formatedData$.pipe(map(data) => {
return formatData2(data)
});
现在 this.totalStatusData$ 如下
{
"passed": 19,
"failed": 14
}
$totalPercentageData = this.totalStatusData$.pipe(map(data) => {
return this.formatData3(data);
})
现在 $totalPercentageData 如下
{
"passed": "57.57%",
"failed": "42.42%"
}
从实际服务数据开始,如何在不破坏 Observable 链的情况下将这些 Observable 链接到 One 而不是 One。