import {Component, OnDestroy, OnInit} from '@angular/core'; import {Subscription} from "rxjs/Subscription"; import {TimerObservable} from "rxjs/observable/TimerObservable"; import {KanbanService} from "./kanban/shared/kanban.service"; const RENEW_TIMER_INITIAL = 300000; const RENEW_TIMER_PERIOD = 300000; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit, OnDestroy{ title = 'app'; authRenewTimer: Subscription; constructor( private kanbanService: KanbanService ) {} public ngOnInit() { let timer = TimerObservable.create(RENEW_TIMER_INITIAL, RENEW_TIMER_PERIOD); this.authRenewTimer = timer.subscribe(() => { this.kanbanService.reload(); }); } public ngOnDestroy() { this.authRenewTimer.unsubscribe(); } }