refactor: digitale Ausgänge über eigenen Service und Redux Thunk laden
- neue Datei fetchDigitalOutputs.ts liest win_da_state und win_da_bezeichnung aus window - fetchDigitalOutputsThunk.ts verwendet den Service und befüllt Redux Slice - entfernt alte Logik aus loadWindowVariables.ts - verbessert Performance und Struktur, lädt Ausgänge nur bei Bedarf
This commit is contained in:
@@ -12,6 +12,7 @@ import { useDispatch } from "react-redux";
|
||||
import { AppDispatch } from "../redux/store";
|
||||
import { setDigitalOutputs } from "../redux/slices/digitalOutputsSlice";
|
||||
import { fetchDigitaleEingaengeThunk } from "../redux/thunks/fetchDigitaleEingaengeThunk";
|
||||
import { fetchDigitalOutputsThunk } from "../redux/thunks/fetchDigitalOutputsThunk";
|
||||
const EinAusgaenge: React.FC = () => {
|
||||
const dispatch = useDispatch<AppDispatch>();
|
||||
const { digitalOutputs, isLoading: isLoadingOutputs } = useDigitalOutputs();
|
||||
@@ -74,6 +75,15 @@ const EinAusgaenge: React.FC = () => {
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
}, [dispatch]);
|
||||
//---------------------------------------------------------
|
||||
useEffect(() => {
|
||||
dispatch(fetchDigitalOutputsThunk());
|
||||
const interval = setInterval(() => {
|
||||
dispatch(fetchDigitalOutputsThunk());
|
||||
}, 10000);
|
||||
return () => clearInterval(interval);
|
||||
}, [dispatch]);
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user