blob: 288f9bd651893fa3a08c43c7f096d998a0b4ceaa [file] [log] [blame]
import { Injectable, Type, ComponentRef } from '@angular/core';
import { LoaderComponent } from './loader.component';
@Injectable()
export class LoaderService {
constructor() {}
private mainLoaderName = 'general';
public registeredLoaders = {};
public register(name: string, loader: LoaderComponent) {
if (!this.registeredLoaders[name]) {
this.registeredLoaders[name] = loader;
}
}
public unregister(name: string) {
if (this.registeredLoaders[name]) {
delete this.registeredLoaders[name];
}
}
public activate(name: string = this.mainLoaderName) {
if (this.registeredLoaders[name]) {
this.registeredLoaders[name].activate();
}
}
public deactivate(name: string = this.mainLoaderName) {
if (this.registeredLoaders[name]) {
this.registeredLoaders[name].deactivate();
}
}
}