【发布时间】:2021-02-21 20:25:22
【问题描述】:
我有多个 REST 请求要做。请求应该按照声明的顺序发生 - 一个在另一个结束之后。
最后我需要做一个动作。
我怎样才能得到它?我认为必须有比级联请求更好的方法。 但我在 RxJS 和异步编程方面做得很差。
this.http.get <any> ("/a").subscribe ((resp) => { foo ();
this.http.get <any> ("/b").subscribe ((resp) => { bar ();
this.http.get <any> ("/c").subscribe ((resp) => { baz (); }}}
);
// action now
【问题讨论】:
-
stackoverflow.com/questions/42888604/… - 通常,RxJS 中的嵌套订阅调用被认为是一种反模式