node.js - 在 Angular 7 中链接多个服务调用是个好主意吗
问题描述
我正在创建一个基本的 MEAN 应用程序,在处理它时,我必须一个接一个地调用多个服务。例如,在下订单时:
PlaceOrder(){
productService.CheckAvailability().subscribe(() => {
if (available){
customerService.GetCustomer().subscribe(() =>{
if(newCustomer){
customerService.CreateCustomer().subscribe(() => {
orderService.CreateOrder().subscribe(() => {
console.log("Order placed");
});
});
}
else //old customer
{
orderService.CreateOrder().subscribe(() => {
console.log("order placed");
});
}
});
} //endif
});
}
现在,我想知道以这种方式链接这些服务调用是否是一个好主意和应用程序设计,或者这种设计是否会影响应用程序的速度和效率。Nodejs 服务器也是如此。在那里,我有连续的数据库更新。
解决方案
推荐阅读
- javascript - 尝试将变量值添加到多数据集数组
- sql - 为什么我的帖子数组在 SQL wordpress 中为空?
- python - Flask send_file 不会返回文件
- python - VSCode 找不到(某些)pylint 模块
- r - sparklyr 中的等效 dplyr::slice
- java - Android studio:为没有源代码的android签名apk
- xquery - Marklogic - 删除版本化集合
- filepond - Filepond 自定义服务器功能
- javascript - 为什么喜欢在我的猫鼬模式中单击按钮时没有更新?
- vb.net - Datatable.Select() 无法过滤包含“#”的值