1 import { Component, OnInit, OnDestroy } from '@angular/core';
3 import { RequestService, RequestStats } from '../shared';
6 selector: 'my-request-stats',
7 templateUrl: './request-stats.component.html',
8 styleUrls: [ './request-stats.component.scss' ]
10 export class RequestStatsComponent implements OnInit, OnDestroy {
11 stats: RequestStats = null;
13 private interval: NodeJS.Timer = null;
15 constructor(private requestService: RequestService) { }
22 if (this.stats.secondsInterval !== null) {
23 clearInterval(this.interval);
28 this.requestService.getStats().subscribe(
39 private runInterval() {
40 this.interval = setInterval(() => {
41 this.stats.remainingMilliSeconds -= 1000;
43 if (this.stats.remainingMilliSeconds <= 0) {
44 setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100);
45 clearInterval(this.interval);