Ionic2 timer

What is ionic timer like visual basic timer?

Did not understand what you are asking.

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

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

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 ();
    }
2 Likes