Я сделал эту функцию, на каждой итерации у меня есть 7 запросов, которые отправляют каждое время environment.dashboard.frequency, но в начале я вижу, что я отправляю на сервер 14 запросов вместо 7:
let requests: Observable<ResourceResponse>[] = initRequests(this.durationService.resourceDataDuration)
timer(0, environment.dashboard.frequency)
.pipe(
takeUntil(this.destroy),
startWith(0),
switchMap(() => forkJoin(requests))
)
.subscribe((responsesArr: ResourceResponse[]) => {
this.updateBegin()
for (const response of responsesArr) {
this.durationService.resourceDurationHandler.setPresentedDataRanges(
response,
this.durationService.resourceDataDuration,
this.durationService.resourcePresnetedDataDurations
)
this.updateMany(response.Resource, response.Response, true)
}
this.updateEnd()
requests = initRequests(this.durationService.resourceDataDuration)
})