2020-10-19 14:10:29 +00:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import {BehaviorSubject} from 'rxjs';
|
2020-12-24 03:14:43 +00:00
|
|
|
import {debug} from '../utility';
|
2020-10-19 14:10:29 +00:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class NavigationService {
|
|
|
|
protected refreshCount = 0;
|
|
|
|
public readonly sidebarRefresh$: BehaviorSubject<[number, boolean]> = new BehaviorSubject<[number, boolean]>([this.refreshCount, true]);
|
2020-11-16 15:37:45 +00:00
|
|
|
public readonly navigationRequest$: BehaviorSubject<string> = new BehaviorSubject<string>('');
|
2020-10-19 14:10:29 +00:00
|
|
|
|
|
|
|
requestSidebarRefresh({ quiet = false }) {
|
|
|
|
this.refreshCount += 1;
|
|
|
|
this.sidebarRefresh$.next([this.refreshCount, quiet]);
|
|
|
|
}
|
2020-11-16 15:37:45 +00:00
|
|
|
|
|
|
|
requestNavigation(pageId: string) {
|
2020-12-24 03:14:43 +00:00
|
|
|
debug('Requesting page navigation:', pageId);
|
|
|
|
debug('Page navigation trace', new Error());
|
|
|
|
|
2020-11-16 15:37:45 +00:00
|
|
|
this.navigationRequest$.next(pageId);
|
|
|
|
}
|
2020-10-19 14:10:29 +00:00
|
|
|
}
|