2019-11-01 19:30:11 +01:00
|
|
|
import {Injectable} from "@angular/core";
|
|
|
|
import {BehaviorSubject, Observable} from "rxjs";
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class SideBarService {
|
|
|
|
|
2019-11-12 16:55:37 +01:00
|
|
|
/**
|
|
|
|
* Set this to true when sidebar items are ready.
|
|
|
|
*/
|
|
|
|
private openSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
|
|
|
|
|
|
/**
|
2019-11-13 11:26:50 +01:00
|
|
|
* Set this variable to false on Init of components that is not needed to have sidebar
|
2019-11-12 16:55:37 +01:00
|
|
|
* and on Destroy set this to true.
|
|
|
|
*/
|
|
|
|
private hasSidebarSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
2019-11-01 19:30:11 +01:00
|
|
|
|
2019-11-05 15:59:06 +01:00
|
|
|
constructor() {}
|
2019-11-01 19:30:11 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|