Rxjs 如何使用开关映射内部的循环获得结果
我有下一个代码,它工作正常。要执行对我的方法fetchDropDownDatabyFederOrimid的请求,现在我需要执行相同的方法x次Rxjs 如何使用开关映射内部的循环获得结果,rxjs,angular10,Rxjs,Angular10,我有下一个代码,它工作正常。要执行对我的方法fetchDropDownDatabyFederOrimid的请求,现在我需要执行相同的方法x次 fetchInProgress(queryString?): Observable<IPerson[]> { let PersonList: IPerson[] = []; return this.getItems<IPerson[]>('', queryString).pipe( take(
fetchInProgress(queryString?): Observable<IPerson[]> {
let PersonList: IPerson[] = [];
return this.getItems<IPerson[]>('', queryString).pipe(
take(1),
switchMap((wls: IPerson[]) => {
PersonList = [...wls];
//const createdbyIds = [...new Set(wls.map((f) => f.createdBy))];
return this.teamPageService.getInformation(wls.createdBy);
}),
map((teams:any) => {
console.log('> teams', teams);
for (let i = 0; i < PersonList.length; i++) {
//update information
}
//console.log('> Final value: ', PersonList);
return PersonList;
})
);
}
但还是没有运气。
有人能帮我吗?我该怎么解决呢?我觉得你的帖子很难理解,你试图解释你的尝试,但对我来说,你到底想实现什么并不清楚。一些基于模型的解释会很好。我不能理解你的代码的头绪或是哪里出了问题(“但还是不走运”
mergeMap((wls: IWalklist[]) => {
//let allIds = wls.contact.map(id => this.getSingleData(id._id) );
let drops: Dropdown[] = [];
walklistList = [...wls];
const allIds = [...new Set(wls.map((f) => f.createdBy))];
return forkJoin(...allIds).pipe(
map((idDataArray) => {
drops.push(
this.teamPageService.getInformation('');
);
return drops;
})
)
}),