![](/img/trans.png)
[英]I want to keep the first toggle opened whenever the page opens. How can this be done?
[英]How to call next observer whenever first is done?
在Ionic 2项目中,我每隔1分钟在提供程序类中从服务器下载数据,每当新数据到来时,我都需要刷新页面类中的图表,那么如何使用可观察对象来实现此目的? 这是简化版本中的代码:
let startTime = new Date(Math.ceil(new Date().getTime() / 60000) * 60000);
this.Source = Rx.Observable.timer(startTime, 60000).timeInterval().pluck('interval');
this.Subscription = this.Source
.subscribe(data => {
this.http.post(this.ConnectionString)
.map(res => res.json())
.subscribe(data => {
//code
});
});
您可以使用Observable.interval
尝试这样
//Time in milleseconds
Observable.interval(15000).flatMap(x => this.http.post(this.ConnectionString))
.map(res => res.json())
.subscribe(data => {
//code
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.