1

I am building an app for a school. Students can scan id cards and enter. On teacher's side application, I am showing number of students present in particular class. Now, I am using refresher to load page to show the number of students.

<ion-content>
  <ion-refresher (ionRefresh)="doRefresh($event)">
    <ion-refresher-content></ion-refresher-content>
  </ion-refresher>
</ion-content>



export class NumberOfStudents{
  doRefresh(refresher) {
    console.log('Begin async operation', refresher);
    setTimeout(() => {
      console.log('Async operation has ended');
      refresher.complete();
    }, 2000);
  }
}

Help me in achieving executing above code automatically in background without pulling to refresh. Give me an idea on how to call the api every 2 minutes or like that without affecting the view.

Sagar Kulkarni
  • 2,072
  • 2
  • 16
  • 25
varun aaruru
  • 2,920
  • 1
  • 20
  • 36

1 Answers1

0

If you don't care if the "refresh" API call take longer than your interval(2 minute), then you can use setInterval():

setInterval(doRefresh, 1000*60*2);
Rohit Gupta
  • 1,368
  • 1
  • 14
  • 30