Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 在所有可观测数据完成后订阅最终可观测数据?_Angular_Angular9_Angular10_Rxjs Observables - Fatal编程技术网

Angular 在所有可观测数据完成后订阅最终可观测数据?

Angular 在所有可观测数据完成后订阅最终可观测数据?,angular,angular9,angular10,rxjs-observables,Angular,Angular9,Angular10,Rxjs Observables,我这里有一个逻辑,它创建了许多可观察的对象,并在每个对象完成后执行回调 from(rows).pipe( concatMap(row => this.uploadItem(row)) ).subscribe(response => { this.currentRowNode.data.uploadStatus = UploadStatus.Success; this.currentRowNode.data.cmsRowId = response.respons

我这里有一个逻辑,它创建了许多可观察的对象,并在每个对象完成后执行回调

from(rows).pipe(
    concatMap(row => this.uploadItem(row))
).subscribe(response => {
    this.currentRowNode.data.uploadStatus = UploadStatus.Success;
    this.currentRowNode.data.cmsRowId = response.responsePayload.cmsRowId
    this.currentRowNode.setData(this.currentRowNode.data);
});

currentRowNode: RowNode;
uploadItem(rowNode: RowNode): Observable<any> {
    this.currentRowNode = rowNode;
    rowNode.data.uploadStatus = UploadStatus.Uploading;
    rowNode.updateData(rowNode.data);
    return this.importService.uploadItem(rowNode.data)
 }
来自(行)。管道(
concatMap(行=>this.uploadItem(行))
).订阅(响应=>{
this.currentRowNode.data.uploadStatus=uploadStatus.Success;
this.currentRowNode.data.cmsRowId=response.responsePayload.cmsRowId
this.currentRowNode.setData(this.currentRowNode.data);
});
currentRowNode:RowNode;
uploadItem(rowNode:rowNode):可观察{
this.currentRowNode=rowNode;
rowNode.data.uploadStatus=uploadStatus.Uploading;
rowNode.updateData(rowNode.data);
返回此.importService.uploadItem(rowNode.data)
}
我的问题是,我希望能够订阅一些东西,告诉我,
uploadItem
已为每个
行调用了


那会去哪里?

你可以创建一个这样的可观察对象

const final$ = of("completed");
使用rxjsconcat操作符,将其与现有的可观测值进行concat,如下所示

const myobs$ = from(rows).pipe(concatMap(row => this.uploadItem(row)));
concat(myobs$, final$).subscribe(response=>{
//your existing code here
if(response=="completed")
{
console.log('all observables completed');
}
});
在这里,我创建了一个