私はこのようなオブザーバブルを得ました:
const original = Observable.of({
a: this.http.get('https://jsonplaceholder.typicode.com/todos/11'),
b: this.http.get('https://jsonplaceholder.typicode.com/todos/22'),
c: this.http.get('https://jsonplaceholder.typicode.com/todos/33')
});
内部のオブザーバブルを解決し、サブスクライブ ハンドラーで次のようなものを取得する必要があります。
{
a: ResponseFromServer,
b: ResponseFromServer,
c: ResponseFromServer,
}
この問題にどのようにアプローチすればよいですか?
ありがとう。
編集:私はそれを理解しました、以下を読んでください。
*Map 演算子resultSelector
が 2 番目の引数として呼び出されるものを使用していたことを知っている人はあまりいないようです。rxjs v6 では、 で同じことができinner map
ます。お見せしましょう。
const original = Observable.of({
a: this.http.get('https://jsonplaceholder.typicode.com/todos/11'),
b: this.http.get('https://jsonplaceholder.typicode.com/todos/22'),
c: this.http.get('https://jsonplaceholder.typicode.com/todos/33')
});
const transformed = original.pipe(
mergeMap(sourceValue =>
forkJoin(_.values(sourceValue)).pipe(map(resolvedHttpRequests => {
// here you have access to sourceValue as well as resolvedHttpRequests so you can do manual join to match the data.
}))
)
)