feat: add progress bar (#66)

Add progress bar for loading data via http requests.

Fixes #65
This commit is contained in:
Abhay Chawla
2018-06-26 17:01:43 +05:30
committed by GitHub
parent 65e1d1ffc2
commit 32b94503dd
6 changed files with 88 additions and 1 deletions
+35
View File
@@ -0,0 +1,35 @@
import { Injectable, EventEmitter } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ProgressBarService {
public updateProgressBar: EventEmitter<any>;
private requestsRunning = 0;
constructor() {
this.updateProgressBar = new EventEmitter();
}
public getRequestsRunning(): number {
return this.requestsRunning;
}
public increase(): void {
this.requestsRunning++;
if (this.requestsRunning === 1) {
this.updateProgressBar.emit('indeterminate');
}
}
public decrease(): void {
if (this.requestsRunning > 0) {
this.requestsRunning--;
if (this.requestsRunning === 0) {
this.updateProgressBar.emit('none');
}
}
}
}