Skip to content

Instantly share code, notes, and snippets.

@dancornilov
Last active January 23, 2019 15:10
Show Gist options
  • Save dancornilov/573f357dd1b3e6079a2c38b625ae7859 to your computer and use it in GitHub Desktop.
Save dancornilov/573f357dd1b3e6079a2c38b625ae7859 to your computer and use it in GitHub Desktop.
Loader Component Service
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Loader } from './loader.model';
@Injectable()
export class LoaderService {
private loader = new BehaviorSubject<Loader>({id: 'global', status: false});
loaderStatus$ = this.loader.asObservable();
constructor() {
}
/**
* Show loader
* @param {string} id
*/
public showLoader(id: string = 'global'): void {
this.loader.next({id, status: true});
}
/**
* Hide loader
* @param {string} id
*/
public hideLoader(id: string = 'global'): void {
this.loader.next({id, status: false});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment