【发布时间】:2023-03-14 12:56:02
【问题描述】:
我将从添加代码开始,我得到的结果,最后我想得到什么,如果可能的话。
我得到的结果是 Array[object, object, ...] 其中 object 是 Array
export class SomeService {
....
....
public someFunction(): MyObject[]{
Observable
.forkJoin(this.userItemsA(userId), this.userItemsB(userId), etc)
.filter(each => {
for (let array of each) {
let x: any = array;
return x.length > 0;
}
})
.map(result => {
return result;
})
.subscribe(result => {
/// what i would like to do for example assuming only 1st array has items
/// do something here with result[0]
/// return MyObject[] from result[0]
});
....
}
}
过滤器结构
我正处于 angular2 和响应式编程的早期学习阶段,我想要进行过滤,以便映射结果仅是具有至少 1 个项目的数组。
谢谢
-
.filter(each => ...
中的数据结构是什么? -
我已经上传了过滤器的结构,谢谢