У меня есть следующий код, который пытается обрабатывать массив конечных точек параллельно:
callApiEndpoint(endpoint: string): Observable<any> {
return this.httpClient
.get<any>(endpoint)
.pipe(
tap(
data =>
console.log(`calling ${endpoint} returned ${JSON.stringify(data)}`),
catchError(ApiCallerComponent.handleError)
)
);
}
getEndpointsToProcess(): string[] {
const result = [];
this.idsToProcess.forEach(element => {
result.push(this.getEndpoint(element));
});
return result;
}
processRequests() {
const endpoints = this.getEndpointsToProcess();
forkJoin(endpoints.map(uri => <Observable<any>>this.callApiEndpoint(uri)))
.pipe(concatAll())
.subscribe(val => console.log(val));
}
Как бы я мог контролировать степень параллельных запросов к серверу API? Кроме того, как я могу сказать, что все запросы были завершены независимо от их результатов?