问题
How to fetch data every 10 minutes in ionic 3 my code is below here..
getStudentStatus() {
let item = JSON.parse(localStorage.getItem('username'))
this.auth.getStudentData(item.username).then(
data => {
this.studentList = data;
}
)
}
Thank's in advance
回答1:
If you want to fetch data every 10 mins you can use rxjs to help you here with an Observable that polls every 10secs.
getStudentStatus() {
let item = JSON.parse(localStorage.getItem('username'))
let poll$ = Observable.interval(10000);
poll$.subscribe(() => this.auth.getStudentData(your logic));
)
来源:https://stackoverflow.com/questions/48255907/fetch-data-every-10-minutes-in-ionic-3-android