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
RxJS v5.x to v6 Update Guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With