Angular2可观察的http得到条件重复
发布时间:2020-12-17 17:33:26 所属栏目:安全 来源:网络整理
导读:我正在使用angular2 observable模式来发出http请求. 我正在尝试有条件地重复http get:我想执行http get,直到满足条件: http.get('url').map(res = { // if the condition is met I should repeat the http get request}).subscribe() 有没有办法有条件地重
我正在使用angular2 observable模式来发出http请求.
我正在尝试有条件地重复http get:我想执行http get,直到满足条件: http.get('url') .map(res => { // if the condition is met I should repeat the http get request }) .subscribe() 有没有办法有条件地重复http get请求? 谢谢, 解决方法
您可以使用
expand运算符.这是一个例子:
let request$= http.get('url'); request$.expand(value => { return value !== 0 ? request$: Rx.Observable.empty() }) .map(res => { //Do mapping here }) .subscribe() (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读