import {Injectable} from "@angular/core"; import {HttpClient} from "@angular/common/http"; import {BehaviorSubject, Observable} from "rxjs"; import {Stakeholder} from "../utils/entities/stakeholder"; @Injectable({ providedIn: "root" }) export class StakeholderService { private stakeholderSubject: BehaviorSubject = null; constructor(private http: HttpClient) { this.stakeholderSubject = new BehaviorSubject(null); } getStakeholder(url: string, alias:string): Observable { return this.http.get(url + '/stakeholder/' + alias); } getStakeholderAsObservable(): Observable { return this.stakeholderSubject.asObservable(); } get stakeholder(): Stakeholder { return this.stakeholderSubject.getValue(); } setStakeholder(stakeholder: Stakeholder) { this.stakeholderSubject.next(stakeholder); } }