monitor-dashboard/src/app/library/sharedComponents/sidebar/sideBar.service.ts

38 lines
881 B
TypeScript
Raw Normal View History

import {Injectable} from "@angular/core";
import {BehaviorSubject, Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class SideBarService {
/**
* Set this to true when sidebar items are ready.
*/
private openSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
/**
* Set this variable to false on Init of components that is not needed to have sidebar
* and on Destroy set this to true.
*/
private hasSidebarSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
constructor() {}
get open(): boolean {
return this.openSubject.getValue();
}
setOpen(value: boolean) {
this.openSubject.next(value);
}
get hasSidebar(): Observable<boolean> {
return this.hasSidebarSubject.asObservable();
}
setHasSidebar(value: boolean) {
this.hasSidebarSubject.next(value);
}
}