Ionic2 timer


#1

What is ionic timer like visual basic timer?


#2

Did not understand what you are asking.


#3

i meant, is there any function/component that can run every x seconds like timer component in visual basic?


#4

It’s javascript. You can just use the setInterval function.


#5
import { Observable } from 'rxjs/Rx';
    //then initialize a variable called subscription, for example.
    subscription;
    i = 0;
    // then start it
    ionViewDidLoad () {
      this.subscription = Observable.interval(1000).subscribe(x => {
      // the number 1000 is on miliseconds so every second is going to have an iteration of what is inside this code.
        console.log (i);
        i++;
      });
    }
    // to unsubscribe the function and stop the iterations
    stopTheIterations () {
      this.subscription.unsubscribe ();
    }

Clock that tracks time