1ngOnInit() {
2 if (!localStorage.getItem('foo')) {
3 localStorage.setItem('foo', 'no reload')
4 location.reload()
5 } else {
6 localStorage.removeItem('foo')
7 }
8}
9
1import { Subscription, timer } from 'rxjs';
2import { switchMap } from 'rxjs/operators';
3
4subscription: Subscription;
5statusText: string;
6
7ngOnInit() {
8 this.subscription = timer(0, 10000).pipe(
9 switchMap(() => this.myservice.checkdata())
10 ).subscribe(result => this.statustext = result);
11}
12
13ngOnDestroy() {
14 this.subscription.unsubscribe();
15}