gpt4 book ai didi

javascript - Angular RXJS 返回 3 个可观察流的数组

转载 作者:行者123 更新时间:2023-12-01 00:46:58 26 4
gpt4 key购买 nike

我需要使用以下 3 个流来创建每个流的数组。 IE:[homePage、mainNavigation、loan_originators]

但这仅返回mainNavigation

  const homePage = this.flamelinkService.getData('homePage');
const mainNavigation = this.flamelinkService.getNav('mainNavigation');
const loan_originators = this.catalogApiService.get('loan_originators', qry);

return mainNavigation.pipe(
concat( homePage, loan_originators),
first(),
tap( async navResolveData => {
// navResolveData = navResolveData[0];
_log('== Navigation Data Resolver ==> ', 't', navResolveData);
if (isPlatformServer(this.platformId)) {
this.transferState.set(INFO_KEY, navResolveData);
}
}),
);

我在这里尝试 forkJoin。但什么也没有

  const homePage = this.flamelinkService.getData('homePage');
const mainNavigation = this.flamelinkService.getNav('mainNavigation');
const loan_originators = this.catalogApiService.get('loan_originators', qry);
return forkJoin([homePage, loan_originators, mainNavigation]).pipe(
first(),
tap( async navResolveData => {
// navResolveData = navResolveData[0];
_log('== Navigation Data Resolver ==> ', 't', navResolveData);
if (isPlatformServer(this.platformId)) {
this.transferState.set(INFO_KEY, navResolveData);
}
}),
);

最佳答案

在这种情况下您可以使用 forkJoin

forkJoin(
[
this.flamelinkService.getData('homePage'),
this.flamelinkService.getNav('mainNavigation'),
this.catalogApiService.get('loan_originators', qry)
]
).subscribe(([res1, res2, res3]) => {
// do something
});

关于javascript - Angular RXJS 返回 3 个可观察流的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57282816/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com