我在组件中使用这个 observable
this.pagedRecords$ =
this.records$.pipe(
map((records) => records
.filter(rec => (!this.filterParams.stream) || rec.streamId === this.filterParams.stream)
.filter(rec => (!this.filterParams.topicId) || rec.topicId === this.filterParams.topicId)
.filter(rec => (!this.filterParams.date || moment.tz(rec.timestamp, rec.timezone)
.isSame(this.filterParams.date.original.tz(rec.timezone), 'day')))
.slice(page * this.pagination.perPage, (page + 1) * this.pagination.perPage - 1)),
tap((records) => {
console.log(records);
this.noRecordings = records.length === 0;
this.cdr.markForCheck();
this.cdr.detectChanges();
}),
repeatWhen(delay(10000)),
takeWhile(records => records.some(rec => rec.status === 'processing') || !this.recordingsLoaded),
tap(() => this.recordingsLoaded = true));
管道按预期工作:轮询结果,直到不再有状态设置为“处理”的项目
这是在模板中使用管道的方式
<ng-container *ngFor="let record of (pagedRecords$|async)">
<audio
*ngIf="browser === 'Chrome' && record?.status==='completed' && (record?.url|fileExtension) === 'mp3'"
controls
controlsList="nodownload"
class="w100">
<source [src]="record?.url" type="audio/webm">
</audio>
<span *ngIf="record?.status==='processing'">
Recording processing
</span>
<div *ngIf="record?.status==='unprocessed'">
<div class="button smallest unset-width" (click)="processRecording(record)">
Process to download
</div>
</div>
<span *ngIf="browser !== 'Chrome'">Not supported in your browser</span>
</ng-container>
即使轮询结束,模板状态也不会更新(我看到控制台日志的所有项目的状态都设置为“已完成”或“未处理”)。
我错过了什么?