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"; import {Router} from "@angular/router"; const TIMER_JIRA_REFRESH = 60000; const TIMER_PAGE_SWITCH = 300000; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit, OnDestroy { reloadJiraIssueTimer: Subscription; pageSwitchTimer: Subscription; constructor( private kanbanService: KanbanService, private router: Router ) {} public ngOnInit() { let timer1 = TimerObservable.create(TIMER_JIRA_REFRESH, TIMER_JIRA_REFRESH); this.reloadJiraIssueTimer = timer1.subscribe(() => { this.kanbanService.reload(); }); let timer2 = TimerObservable.create(TIMER_PAGE_SWITCH, TIMER_PAGE_SWITCH); this.pageSwitchTimer = timer2.subscribe(() => { // navigate to next page // this.router.navigate(); console.log("pageSwitch"); }); } public ngOnDestroy() { this.reloadJiraIssueTimer.unsubscribe(); this.pageSwitchTimer.unsubscribe(); } }