Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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
Http rxjs-将订阅结果传递给另一个函数_Http_Rxjs_Httpclient_Angular6_Subscribe - Fatal编程技术网

Http rxjs-将订阅结果传递给另一个函数

Http rxjs-将订阅结果传递给另一个函数,http,rxjs,httpclient,angular6,subscribe,Http,Rxjs,Httpclient,Angular6,Subscribe,请你帮我指引正确的方向好吗 我试图从一个旧的Http REST服务中提取记录,重新构造数据,然后将其发布到firebase 我不确定这是否是完全错误的方法,或者我完全误解了observable的方法。非常感谢您的指导。如何将此新列表发送到另一个DataService函数:exportToFirebase(新列表) onServiceCall(){ this.httpDataService.getData().subscribe((itemData)=>{ this.itemDataJSON=i

请你帮我指引正确的方向好吗

我试图从一个旧的Http REST服务中提取记录,重新构造数据,然后将其发布到firebase

我不确定这是否是完全错误的方法,或者我完全误解了observable的方法。非常感谢您的指导。如何将此新列表发送到另一个DataService函数:exportToFirebase(新列表)

onServiceCall(){
this.httpDataService.getData().subscribe((itemData)=>{
this.itemDataJSON=itemData;
if(this.itemDataJSON){
this.itemDataJSON.forEach(函数(值){
让new_listing=新列表(value.id、value.name、value.category);
//console.log(新的_列表);
//如何将此新列表发送到另一个firebaseDataService函数exportToFirebase(新列表);
});
}
});
}
使用模拟的http和firebase服务,这可以满足您的需求

// --- make http call
httpCall.pipe(
  // --- construct an array of "new_listing" (of just one, up to u) and pass along the observable chain
  concatMap(httpNumbers => of(...httpNumbers)),
  // --- make the firebase call
  concatMap(number => firebaseCall(number))
).subscribe(val => console.log(val))

希望这有帮助。如果这没有意义,那么您需要继续阅读。

您不能“发送”数据,但另一方面,您可以提取数据。因此,不要从
onServiceCall()
发送它,而是在您的
数据服务上调用
this.httpDataService.getData()
,然后使用
.switchMap
.map
对结果执行任何您想要的操作。exportToFirebase的函数签名是什么
exportToFirebase
返回什么?