This commit is contained in:
2025-11-13 15:37:50 +07:00
parent b3fa94f904
commit 1664be0c8b
7 changed files with 56 additions and 22 deletions

View File

@@ -1,27 +1,27 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { IDropAct } from '../../interfaces/dashboard.interface';
import { IDropAct, IStateDrop } from '../../interfaces/dashboard.interface';
@Injectable({
providedIn: 'root'
})
export class DashboardStateService {
// ประกาศ BehaviorSubject ด้วย Interface
private productState = new BehaviorSubject<IDropAct | null>(null);
private dashboardState = new BehaviorSubject<IStateDrop | null>(null);
// ส่ง Observable ไปให้ components subscribe
getStateResult(): Observable<IDropAct | null> {
return this.productState.asObservable();
getStateResult(): Observable<IStateDrop | null> {
return this.dashboardState.asObservable();
}
// เซ็ท state
setStateResult(product: IDropAct): void {
this.productState.next(product);
setStateResult(product: IStateDrop): void {
this.dashboardState.next(product);
}
// เคลียร์ state
clearState(): void {
this.productState.next(null);
this.dashboardState.next(null);
}
// ดึงค่า current state (ไม่ใช่ observable)