import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, ReplaySubject, tap } from 'rxjs'; import { Navigation } from 'app/core/navigation/navigation.types'; @Injectable({ providedIn: 'root', }) export class NavigationService { private _navigation: ReplaySubject = new ReplaySubject(1); /** * Constructor */ constructor(private _httpClient: HttpClient) {} // ----------------------------------------------------------------------------------------------------- // @ Accessors // ----------------------------------------------------------------------------------------------------- /** * Getter for navigation */ get navigation$(): Observable { return this._navigation.asObservable(); } // ----------------------------------------------------------------------------------------------------- // @ Public methods // ----------------------------------------------------------------------------------------------------- /** * Get all navigation data */ get(): Observable { return this._httpClient.get('api/common/navigation').pipe( tap((navigation) => { this._navigation.next(navigation); }) ); } }