dropdown
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user