【发布时间】:2019-04-19 12:04:24
【问题描述】:
我正在尝试使用 rxjs 和 angular 创建连续轮询。以下是我的要求的实现。
https://stackblitz.com/edit/angular-sq3ke5
ngOnInit() {
const bitcoin$ = this.http.get('https://blockchain.info/ticker');
this.polledBitcoin$ = timer(0, this.timeInterval).pipe(
merge(this.manualRefresh),
concatMap(_ => bitcoin$),
map((response: {EUR: {last: number}}) => {
console.log(new Date() +" >> " + response.EUR.last)
return response.EUR.last;
}),
);
}
但是在这个例子中,我添加了轮询间隔,我希望它根据用户输入的值进行更新。但是,文本输入的任何更改都不会反映在轮询间隔中。 有人可以帮我实现这个结果吗?
提前致谢。
【问题讨论】:
-
你想更新什么?间隔?比如:5000 -> 10000?
-
为了清楚起见,这看起来代码来自blog.strongbrew.io/rxjs-polling。问题是询问如何将轮询计时器重置为新的输入值。
-
是的,没错
标签: angular rxjs angular-httpclient ajax-polling