Angular 角度-将多个观测值链接在一起

Angular 角度-将多个观测值链接在一起,angular,rxjs,observable,rxjs-pipeable-operators,Angular,Rxjs,Observable,Rxjs Pipeable Operators,我有三个服务返回可观察的。第一个返回配方列表,第二个获取给定配方的所有配料,最后一个获取给定配料类型的数量。我想连续调用这三个函数,将前面的信息传递给下一个调用,以便返回的响应可以映射到相同的初始配方列表。基本上,每次连续调用都会增加先前返回的信息,并且对象列表的复杂性会随着每次连续调用而增加。我还需要对每个返回应用自定义映射。我还需要他们同时解决,这样我就可以简单地订阅最终结果。我知道我可能需要使用switchMap或concatMap,但我不确定如何构造它 任何帮助都将不胜感激 我的服务调用

我有三个服务返回可观察的。第一个返回配方列表,第二个获取给定配方的所有配料,最后一个获取给定配料类型的数量。我想连续调用这三个函数,将前面的信息传递给下一个调用,以便返回的响应可以映射到相同的初始配方列表。基本上,每次连续调用都会增加先前返回的信息,并且对象列表的复杂性会随着每次连续调用而增加。我还需要对每个返回应用自定义映射。我还需要他们同时解决,这样我就可以简单地订阅最终结果。我知道我可能需要使用switchMap或concatMap,但我不确定如何构造它

任何帮助都将不胜感激

我的服务调用及其映射示例

获取食谱

让allRecipes:Observable=this.recipeListService.GetRecipesFromAirtable(
所有类型、所有配置、所有预处理样式、所有族、muddlingReq、,
所有主要组件、所有次要组件、recipeName
).pipe(映射(响应=>{
让所有配方:RecipeModel[]=response.records.map(
recipeObj=>{
//console.log(recipeObj.fields);
let模型:RecipeModel={
id:recipeObj.fields[“配方id”],
名称:recipeObj.fields[“name”],
变体:“”,
版本:0,
类型:recipeObj.fields[“类型”]
}
let variant:string=recipeObj.fields[“variant”];
if(variant!==null&&variant!==未定义){
model.variant=变量;
}
let version:number=recipeObj.fields[“version”];
if(版本!==null&&version!==undefined&&isNaN(版本)!==true){
model.version=版本;
}
收益模型;
}
)
返回所有配方;
}));
获取配料

let allIngredients:Observable=this.ingredientsservice.getingredientsfromirtable(recipe.id)
.烟斗(
映射(响应=>{
让AllingRedientObjects:IngredientModel[]=response.records.map(
IngreditoBj=>{
let模型:IngredientModel={
订单:IngRedientObject.fields[“订单”],
名称:ingredientObj.fields[“配料名称”][0],
限定符:IngRedientObject.fields[“限定符”],
可选:IngRedientBj.fields[“可选”]?IngRedientBj.fields[“可选”]:false,
amuntreq:{},
备注:ingredientObj.fields[“备注”]
}
让所有字段:[string,string][][][[Cups”,“cup”,“oz”,“盎司”,“毫升”,“毫升”,“数量”,“克”,“克],
[“破折号”、“]、[“酒匙”、“酒匙”]、[“茶匙”、“茶匙”]、[“杂项”、“];
对于(设i=0;i
获取配料数量

让IngRedientQuantities:Observable=this.inventoryService.GetIngRedientQuantities fromAirTable(
inventoryName,ingredientName)
.烟斗(
映射(响应=>{
设数量=0;
让alllikorobjs=response.records.map(
liquorObj=>{
让模型={
品牌:Liqorobj.fields[“品牌”][0],
desc:liquerobj.fields[“Description”][0],
体积:liquerobj.fields[“当前体积(mL)”]
}
if(模型卷中的“特殊值”){
模型体积=-1;
}
如果(模型体积>0){
数量+=模型体积;
}
//收益模型;
}
)
退货数量;
}));
到目前为止,由于Elias Dal Ben的帮助,我已经解决了以下问题

让allRecipes:Observable=this.getAllRecipesObservable(this.allDrinkTypes,
this.alldrinkocassions、this.allPreparationStyles、this.allFamilies、this.muddlingRequired、,
this.allPrimaryComponents、this.allSecondaryComponents、this.recipeNameToFind)
.烟斗(
点击(所有配方=>{
调试('Recipes('+allRecipes+'));
}),
concatMap(数据=>{
让所有配方=数据;
allRecipes.map(
配方=>{
让AllingElements:Observable=this.GetAllingElementsObservable(配方);
联合元件、管道(
轻触(所有要素=>{
调试('Components('+AllingElements+'));
}),
concatMap(数据=>{
让AllingElements=数据;
AllingElements.map(
成分=>{
let数量:可观察=
this.getIngredientQuantityObservable(this.inventoryAddr,component.type.name);
管道数量(
点击(数量=>{
调试('Quantity('+Quantity+'));
})
)
退货数量;
}
)
})
)
返回所有元素;
}
)
返回所有配方;
})
)
然而在第一行allRecipes给了我一个错误

"
let result = allRecipes.pipe(
  concatMap(recipes => allIngredients.pipe(
     concatMap(ingredients => ingredientQuantity.pipe(
        map(quantity => [ ...ingredients, ...recipes, quantity ])
     ))
  ))
)