blob: 288f9bd651893fa3a08c43c7f096d998a0b4ceaa [file] [log] [blame]
Israel Lavib2a3ace2018-08-07 10:54:17 +03001import { Injectable, Type, ComponentRef } from '@angular/core';
2import { LoaderComponent } from './loader.component';
3
4@Injectable()
5export class LoaderService {
6
7 constructor() {}
8
9 private mainLoaderName = 'general';
10
11 public registeredLoaders = {};
12
13 public register(name: string, loader: LoaderComponent) {
14 if (!this.registeredLoaders[name]) {
15 this.registeredLoaders[name] = loader;
16 }
17 }
18
19 public unregister(name: string) {
20 if (this.registeredLoaders[name]) {
21 delete this.registeredLoaders[name];
22 }
23 }
24
25 public activate(name: string = this.mainLoaderName) {
26 if (this.registeredLoaders[name]) {
27 this.registeredLoaders[name].activate();
28 }
29 }
30
31 public deactivate(name: string = this.mainLoaderName) {
32 if (this.registeredLoaders[name]) {
33 this.registeredLoaders[name].deactivate();
34 }
35 }
36
37}