Daten von Server alle 10 Sekunden holen und aktualisieren in dashboard.js, setInterval ist in _app.js
This commit is contained in:
@@ -13,11 +13,17 @@ function MyApp({ Component, pageProps }) {
|
||||
useEffect(() => {
|
||||
const loadAndStoreVariables = async () => {
|
||||
const variables = await loadWindowVariables();
|
||||
store.dispatch(setVariables(variables)); // Speichere die geladenen Variablen im Redux Store
|
||||
store.dispatch(setVariables(variables));
|
||||
};
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
loadAndStoreVariables();
|
||||
loadAndStoreVariables(); // Initial load
|
||||
|
||||
// Interval for updating the Redux store every 10 seconds
|
||||
const intervalId = setInterval(loadAndStoreVariables, 10000);
|
||||
|
||||
// Cleanup interval when component unmounts
|
||||
return () => clearInterval(intervalId);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user