我有一个返回给我一个
如果有可能的话,我想保留原始observable并使用运算符来获得所需的结果。
由于observable中唯一的项是数组,因此在该情况下,管道化
这里有一些示例代码,类似于我正在尝试实现的实现。
Array<string>
的api,根据原始id(一对多)。我需要在每个id上进行http请求,以从api中获取关联数据。我无法想出如何将Observable<string[]>
映射到Observable<DataType[]>
。如果有可能的话,我想保留原始observable并使用运算符来获得所需的结果。
由于observable中唯一的项是数组,因此在该情况下,管道化
map
运算符无效。这里有一些示例代码,类似于我正在尝试实现的实现。
getIds = (originalId: string) => {
return this.http.get<string[]>(url);
}
getDataFromIds = (originalId: string): Observable<DataType[]> => {
const ids$ = this.getIds(originalId);
// Make http calls for each of the items in the array.
result = ids$.pipe();
return result;
}