rxjs: получить дубликаты HTTP-запросов в первом отправляемом мною наборе

Я сделал эту функцию, на каждой итерации у меня есть 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)
      })

person lior katz    schedule 24.08.2020    source источник
comment
Вам действительно нужно начать здесь?   -  person MoxxiManagarm    schedule 24.08.2020


Ответы (1)


timer(0, environment.dashboard.frequency) - ›dueTime = 0 -› не нужно startWith

person Petrus Nguyễn Thái Học    schedule 24.08.2020