Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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 使用RxJS ForkJoin操作符_Angular_Typescript_Rxjs_Fork Join - Fatal编程技术网

Angular 使用RxJS ForkJoin操作符

Angular 使用RxJS ForkJoin操作符,angular,typescript,rxjs,fork-join,Angular,Typescript,Rxjs,Fork Join,如何使用RxJS ForkJoin操作符重写此代码 this.arrItems.forEach((项目)=>{ this.objectService.update(item.subscribe(); }); //对象外观 公共更新(itemObject:itemObject):可观察{ 让observable=this.objectService.update(this.map(itemObject)); 可观测回波 .flatMap(objective=>this.getItemObject(

如何使用RxJS ForkJoin操作符重写此代码

this.arrItems.forEach((项目)=>{
this.objectService.update(item.subscribe();
});
//对象外观
公共更新(itemObject:itemObject):可观察{
让observable=this.objectService.update(this.map(itemObject));
可观测回波
.flatMap(objective=>this.getItemObject(itemObject.id))
.catch(error=>Observable.throw(error));
}
//对象服务
公共更新(项目:T):可观察{
返回此.http.put(this.url+'/'+item.id,item)
.接住(这个.把手错误);
}
我的样本:

const streams=this.arrtimes.map(item=>
this.objectService.update(项目)
);
forkJoin(…streams.subscribe();
但是,我得到了一个错误:

“void[]”类型的参数不能分配给“SubscribableOrPromise”类型的参数。 类型“void[]”不可分配给类型“PromiseLike”。
类型“void[]”中缺少属性“then”`


是打字错误吗<代码>让可观察;this.objectService.update(this.map(itemObject))应该是
let observable=this.objectService.update(this.map(itemObject))@joyBlanks,这是打字错误。谢谢你,你可以试试
forkJoin(streams)
而不是
forkJoin(…streams)
??@joyBlanks我试过了。错误是一样的。我使用的是rxjs版本5.5,我认为map是不可阻止的代码,请尝试使用for循环或forEach并将其推入streams数组。