大佬教程收集整理的这篇文章主要介绍了angularjs – 如何在rxjs中使用Observable.interval多个http请求(forkjoin),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
>并行调用多个http请求(forkJoin)
>间隔运行这些请求(轮询)
>仅在订户有新数据时才向订户发送数据(不同)
我只用forkJoin(#1)成功了.
仍然需要一些帮助#2& #3
我为此创建了一个plunker,
https://embed.plnkr.co/iIe6pi1hwXjwvF1wIN42/
谢谢你的帮助.
// interval every 10 seconds Observable.interval(1000) // we probably only need one set of AJAX calls running at a time,// so use switchMap here. .switchMap(() => // wait for both of these to complete before emitTing Observable.forkJoin( // get posts this.searchservice.getPosts() // if that GET fails handle it somehow (returning an observablE) .catch(handlePostsErrors),// get comment in parallel to posts this.searchservice.getPostComment(1) // if that GET fails,handle it like above .catch(handlePostCommentErrors) ) ) // posts and comment will come through in an array because of forkJoin .subscribe(([posts,comment]) => doSomething(posts,comment))
以上是大佬教程为你收集整理的angularjs – 如何在rxjs中使用Observable.interval多个http请求(forkjoin)全部内容,希望文章能够帮你解决angularjs – 如何在rxjs中使用Observable.interval多个http请求(forkjoin)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。