2

在我的代码中,我打开了一个matDialog允许的 XLSX 提取。

打开这个matDialog时,数据被加载到 中ngOnInit(),这可能需要一些时间。这就是为什么我使用combineLatest()withfilter()允许我等待三个查询的结果以允许提取。我现在想添加一个mat-progress-bar determinate以查看提取的去向。为此,我希望能够根据progress收到的每个结果修改我的变量。

所以我map(result => {this.progress = this.progress + 30;}在每个请求上都使用了来增加进度。它有效,但打破了我的combineLatest(). 进度停止在 90%,我找不到解决方案。

代码:

this.subscriptions$.add(combineLatest([
    this.storeWallets.loadInvoiceExtractionProduct(this.selectedWallet).pipe(
        //map(result => { this.progress = this.progress + 30; }),
        catchError(err => {
            console.error(err.message);
            return of(err);
        })
    ),
    this.storeWallets.loadInvoiceExtractionSupport(this.selectedWallet).pipe(
        //map(result => { this.progress = this.progress + 30; }),
        catchError(err => {
            console.error(err.message);
            return of(err);
        })
    ),
    this.storeWallets.loadInvoiceExtractionTraining(this.selectedWallet).pipe(
        //map(result => { this.progress = this.progress + 30; }),
        catchError(err => {
            console.error(err.message);
            return of(err);
        })
    ),
    ]).pipe(
        filter(results => results.every(res => !!res))
    ).subscribe(results => {
        //this.progress = 100;
        document.body.style.cursor = "default";
        this.waitExtraction = false;
    })
);

谢谢你的帮助。

4

1 回答 1

2

这一行:

map(result => { this.progress = this.progress + 30; }),

将获取每个结果并返回undefined,因为没有 return 语句(因此filter将过滤掉结果,并且不会运行订阅者)。替换maptap操作员,它应该可以工作。

于 2019-09-23T08:42:00.880 回答