aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/customLoader/custom-loader.service.ts
blob: 398eac2339ab73eba9399601d918613b7323cfb9 (plain)
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
import {Injectable} from "@angular/core";
import {LoaderComponent} from "./custom-loader.component";

@Injectable()
export class LoaderService {

  private mainLoaderName = 'general';
  public registeredLoaders = {};

  register(name: string, loader: LoaderComponent) {
    if (!this.registeredLoaders[name]) {
      this.registeredLoaders[name] = loader;
    }
  }

  unregister(name: string) {
    if (this.registeredLoaders[name]) {
      delete this.registeredLoaders[name];
    }
  }

  activate(name: string = this.mainLoaderName) {
    if (this.registeredLoaders[name]) {
      this.registeredLoaders[name].activate();
    }
  }

  deactivate(name: string = this.mainLoaderName) {
    if (this.registeredLoaders[name]) {
      this.registeredLoaders[name].deactivate();
    }
  }

}