-interface

-service

-เพิ่มเทคนิค การส่ง ผ่านข้อมูล
This commit is contained in:
2025-11-13 14:53:37 +07:00
parent 37ca45701b
commit b3fa94f904
4 changed files with 92 additions and 50 deletions

View File

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