最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - forkJoin([]) requests are being cancelled - Stack Overflow

programmeradmin3浏览0评论

I am trying to do parallel requests with forkJoin but sometimes for no reason one of the request is cancelled or one of requests returns 200 but data Failed to load response data . If I make sepratae requests they work as expected.

  private _getGeneralEventInfo() {
    const id = this.route.snapshot.paramMap.get('id');

    if (id) {
      // Working if make separate requests
      // this._getEventInfo(id).subscribe();
      // this.typeOfService.getTypeOfServices().subscribe();
      // this.workOrder.getEquipments().subscribe();

      forkJoin([
        this._getEventInfo(id),
        this.typeOfService.getTypeOfServices(),
        this.workOrder.getEquipments(),
      ])
        .pipe(
          isLoading(v => this.$isLoading.set(v)),
          takeUntilDestroyed(this.destroyRef),
        )
        .subscribe();
    }
  }


export const isLoading = <T>(stateChanged: (state: boolean) => void) => 
  function wrapOperatorFunction(source: Observable<T>): Observable<T> { 
    stateChanged(true); 
    return source.pipe(finalize(() => stateChanged(false))); 
  };

sometimes 200 but with failed data

sometimes cancelled

发布评论

评论列表(0)

  1. 暂无评论