You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/app/service/navigation.service.ts

32 lines
1.2 KiB

import { Injectable } from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {debug} from '../utility';
@Injectable({
providedIn: 'root'
})
export class NavigationService {
protected refreshCount = 0;
public readonly sidebarRefresh$: BehaviorSubject<[number, boolean]> = new BehaviorSubject<[number, boolean]>([this.refreshCount, true]);
public readonly navigationRequest$: BehaviorSubject<string> = new BehaviorSubject<string>('');
public readonly initializationRequest$: BehaviorSubject<number> = new BehaviorSubject<number>(0);
public readonly initialized$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
requestSidebarRefresh({ quiet = false }) {
this.refreshCount += 1;
this.sidebarRefresh$.next([this.refreshCount, quiet]);
}
requestNavigation(pageId: string) {
debug('Requesting page navigation:', pageId);
debug('Page navigation trace', new Error());
this.navigationRequest$.next(pageId);
}
requestInitialization() {
debug('Requesting application initialization');
this.initializationRequest$.next(this.initializationRequest$.getValue() + 1);
}
}