Last active
January 23, 2019 15:10
-
-
Save dancornilov/573f357dd1b3e6079a2c38b625ae7859 to your computer and use it in GitHub Desktop.
Loader Component Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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