在我的代码中,打开一个matDialog
,允许XLSX提取。
打开此matDialog
时,数据会加载到ngOnInit()
中,这可能需要一些时间。
这就是为什么我将combineLatest()
与filter()
一起使用的原因,使我可以等待三个查询的结果以允许提取。
我现在想添加一个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;
})
);
感谢您的帮助。
答案 0 :(得分:2)
此行:
map(result => { this.progress = this.progress + 30; }),
将获取所有结果并返回 undefined ,因为没有return语句(因此filter
将过滤出结果,并且订阅服务器将不会运行)。将map
替换为tap
运算符,它应该可以工作。