获得以前的可观察结果,以加入管道RXJS
第一个HTTP调用以获取发货数据 如果发货数据不可用 将停止显示错误
如果发货数据可用我需要致电第二和第三个呼叫paralalley
我使用叉子加入来调用paralell请求,并在获取叉子加入数据之后如何在叉子上加入地图方法中使用装运数据。
from(getShipment(this.data.CardId))
.pipe(
filter(shipmentData => shipmentData != undefined),
tap(shipmentData => {
if (shipmentData.ShipmentId === null || shipmentData.ShipmentId === "") {
throw "Shipment needs to be connected"
}
}),
//I NEED TO PASS THIS SHIPMENT DATA TO FORK JOIN PIPE METHOD
map(shipmentData => shipmentData),
concatMap(shipmentData =>
forkJoin([
getOrderLineAllocationByCardIdObservable(this.data.CardId),
getLotsByCardIdObservable(this.data.CardId)
])
.pipe(
filter(response => response != undefined),
map(([inventoryData, lotsData],shipmentData) => {
//I NEED TO ACCESS SHIPMENT DATA IN HERE
//SHIPMENT DATA NOT AVAILABLE IN HERE
})
)
),
// Catch errors thrown above
catchError(error => {
return EMPTY;
}),
// Always finish by Hiding Loading indicator
finalize(() => this.store.dispatch(setLoadingSpinner({showLoading: false})))
)
.subscribe();
First Http call to fetch Shipment Data
IF shipment data is NOT AVAILABLE exceution will be stop with showing error
IF shipment data is AVAILABLE i need to call second and third calls paralalley
I used fork join to call paralell request and after fetching fork join data how to use shipment data inside in the fork join map method.
from(getShipment(this.data.CardId))
.pipe(
filter(shipmentData => shipmentData != undefined),
tap(shipmentData => {
if (shipmentData.ShipmentId === null || shipmentData.ShipmentId === "") {
throw "Shipment needs to be connected"
}
}),
//I NEED TO PASS THIS SHIPMENT DATA TO FORK JOIN PIPE METHOD
map(shipmentData => shipmentData),
concatMap(shipmentData =>
forkJoin([
getOrderLineAllocationByCardIdObservable(this.data.CardId),
getLotsByCardIdObservable(this.data.CardId)
])
.pipe(
filter(response => response != undefined),
map(([inventoryData, lotsData],shipmentData) => {
//I NEED TO ACCESS SHIPMENT DATA IN HERE
//SHIPMENT DATA NOT AVAILABLE IN HERE
})
)
),
// Catch errors thrown above
catchError(error => {
return EMPTY;
}),
// Always finish by Hiding Loading indicator
finalize(() => this.store.dispatch(setLoadingSpinner({showLoading: false})))
)
.subscribe();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需删除
shipmentData
作为您的地图功能的参数,它已经在那里:可运行的示例:
https://stackblitz.com/edit/edit/redit/rxjs-t5mzxy?file= index。 TS
Just remove
shipmentData
as argument from your map function, its already there:runnable example:
https://stackblitz.com/edit/rxjs-t5mzxy?file=index.ts