How do I call a save function every two minutes in Angular2?
rxjs 6
import { interval } from 'rxjs';
interval(2000 * 60).subscribe(x => {
doSomething();
});
rxjs 5
You can either use
import {Observable} from 'rxjs'; // Angular 6
// import {Observable} from 'rxjs/Rx'; // Angular 5
Observable.interval(2000 * 60).subscribe(x => {
doSomething();
});
or just setInterval()
Hint:
Angular >= 6.0.0 uses RxJS 6.0.0 Angular Changelog 6.0.0