Http rxjs-将订阅结果传递给另一个函数
请你帮我指引正确的方向好吗 我试图从一个旧的Http REST服务中提取记录,重新构造数据,然后将其发布到firebase 我不确定这是否是完全错误的方法,或者我完全误解了observable的方法。非常感谢您的指导。如何将此新列表发送到另一个DataService函数:exportToFirebase(新列表)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
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
返回什么?