0

我是 RXJS 的新手。我需要呈现具有特定顺序的表格。我已阅读并检查运算符 concatMap 是否执行了一个过程,并且在前一个完成之前不会开始下一个。

考虑到这一点,我创建了这个实现。

我创建了这个实现:

let startingPositions: number[] = [0, 2000, 4000, 6000];

    let Chunk$: Observable<IResponse> = from(startingPositions).pipe(
      concatMap((position: number) => {

        return this.ldaService.getFilteredData(this.defaultChild, this.module, { Filters: newArray, Sorts: this.sortChildBy, MininumNotStrictShouldMatch: mininumNotStrictShouldMatch ?? undefined }, false, position, batchSize)
      })
    );

    Chunk$.subscribe((res: IResponse) => {
      this.tagChild = this.tagChild.concat(res.documents)
      this.childLoading = false
      retry(3)
    }, catchError(() => {
      console.log('there was an error')
      return EMPTY
    })
    )

这可以正常工作,但仅适用于startingPositions 数组中的第一个位置。

我需要这个来通过startingPositions中的所有项目。

我看到的所有文档和示例都与我正在做的事情相似。

我对自己做错了什么感到有些困惑。

我不知道这是否对这种情况有用,但这是 getFilteredData 方法:

  public getFilteredData(index: string, module: string, filteredOptions: ISearchDto = {},
    getAll: boolean = false, from: number = 0, size: number = 30): Observable<IResponse> {
    // return this.http.post<IOnce>(this.BASE_URL + '/lda/once/Get/' + value, filteredOptions, {
    return this.http.post<IResponse>(this.BASE_URL + '/lda/' + module + '/Get/' + index, filteredOptions, {
      params: {
        size: size,
        from: from,
        indexName: false,
        // strict: strict,
        getAll: getAll
      },

    }).pipe(map(res => IResponseAdapter(res)))
  }
4

0 回答 0