Files
micro-frontend/ng-ttc-frontend/src/app/services/state/project-state.service.ts

33 lines
1017 B
TypeScript
Raw Normal View History

2025-11-23 18:43:10 +07:00
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);
}
}