-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadingService.ts
52 lines (41 loc) · 1.01 KB
/
LoadingService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Injectable, EventEmitter } from '@angular/core';
export class LoadingService
{
public static loadings: LoadingObj[] = new Array();
constructor() { }
public static getLoading(elementName)
{
if (this.checkExits(elementName))
this.addLoading(elementName);
let load = LoadingService.loadings.find(o => o.Name == elementName);
return load;
}
public static show(elementName)
{
let loader = this.getLoading(elementName);
debugger;
loader.loading.emit(true);
}
public static hide(elementName)
{
let loader = this.getLoading(elementName);
loader.loading.emit(false);
}
private static checkExits(elementName: string)
{
return LoadingService.loadings.find(o => o.Name == elementName) == null
}
private static addLoading(elementName)
{
LoadingService.loadings.push(new LoadingObj(elementName));
}
}
export class LoadingObj
{
constructor(
public Name: string,
public loading: EventEmitter<any> = new EventEmitter()
)
{
}
}