33 lines
1017 B
TypeScript
33 lines
1017 B
TypeScript
|
|
import { Injectable } from '@angular/core';
|
||
|
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||
|
|
import { IProjectSearchResponse, ITransactionSearchResponse } from '../../interfaces/dashboard.interface';
|
||
|
|
|
||
|
|
@Injectable({
|
||
|
|
providedIn: 'root'
|
||
|
|
})
|
||
|
|
export class ProjectStateService {
|
||
|
|
private projectState = new BehaviorSubject<IProjectSearchResponse | null>(null);
|
||
|
|
private transactionState = new BehaviorSubject<ITransactionSearchResponse | null>(null);
|
||
|
|
|
||
|
|
getProjectState(): Observable<IProjectSearchResponse | null> {
|
||
|
|
return this.projectState.asObservable();
|
||
|
|
}
|
||
|
|
|
||
|
|
setProjectState(project: IProjectSearchResponse): void {
|
||
|
|
this.projectState.next(project);
|
||
|
|
}
|
||
|
|
|
||
|
|
getTransactionState(): Observable<ITransactionSearchResponse | null> {
|
||
|
|
return this.transactionState.asObservable();
|
||
|
|
}
|
||
|
|
|
||
|
|
setTransactionState(transaction: ITransactionSearchResponse): void {
|
||
|
|
this.transactionState.next(transaction);
|
||
|
|
}
|
||
|
|
|
||
|
|
clearState(): void {
|
||
|
|
this.projectState.next(null);
|
||
|
|
this.transactionState.next(null);
|
||
|
|
}
|
||
|
|
}
|