gpt4 book ai didi

angular - forkjoin 是否按特定顺序返回结果?

转载 作者:太空狗 更新时间:2023-10-29 17:36:50 27 4
gpt4 key购买 nike

我的应用程序将进行多个并行 http 调用。它基于 switch-fall though 逻辑,因此查询的数量会有所不同(1、2 或 3 次调用)。有没有办法让我知道哪个电话首先返回?即要么分配一个 key ,要么它根据列表中的 http 请求以有序的方式返回?

两种方式都适合我。我只需要找到一种方法,将正确的结果与正确的调用相匹配。

最佳答案

是的,它返回结果的顺序与您在数组中发出请求的顺序相同

例子,

const bothrequests= Observable.combineLatest(
this.http.get('https://testdb1.com/.json').map((res: Response) => res.json()),
this.http.get('https://testdb2.com/.json').map((res: Response) => res.json())
)
bothrequests.subscribe(latestValues => {

});

关于angular - forkjoin 是否按特定顺序返回结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47282461/

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