import { Injectable } from '@angular/core'; import {BehaviorSubject} from 'rxjs'; import {environment} from '@src/environments/environment'; import {first} from 'rxjs/operators'; import {HttpWrapperService} from '@app/_services/http-wrapper.service'; @Injectable({ providedIn: 'root' }) export class LocationService { locations: any = ''; private locationsList = new BehaviorSubject(this.locations); locationsSubject = this.locationsList.asObservable(); constructor( private httpWrapperService: HttpWrapperService, ) { } getLocations(): void { this.httpWrapperService.get(`${environment.cicCacheUrl}/locations`).pipe(first()).subscribe(res => this.locationsList.next(res.body)); } }