Skip to content

Commit

Permalink
[ENH] cyclical polling from frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
dragarthPl committed Apr 13, 2024
1 parent 7d9d199 commit c5653c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
19 changes: 18 additions & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import homePeriscopeLogo from './home-periscope.png';
import './App.css';
import React from 'react';
import React, {useEffect} from 'react';

import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
Expand All @@ -13,9 +13,26 @@ import HeatingTemperature from './features/temperature/HeatingTemperature';
import MixerTemperature from "./features/temperature/MixerTemperature";
import WaterHeaterTemperature from './features/temperature/WaterHeaterTemperature';
import StoveState from "./features/stoveState/StoveState";
import {store} from "./store";
import {
fetchHeatingTemperature,
fetchMixerTemperature,
fetchWaterHeaterTemperature
} from "./features/temperature/temepratureSlice";
import {fetchStoveState} from "./features/stoveState/stoveStateSlice";


function App() {
useEffect(() => {
const intervalId = setInterval(() => {
store.dispatch(fetchHeatingTemperature());
store.dispatch(fetchMixerTemperature());
store.dispatch(fetchWaterHeaterTemperature());
store.dispatch(fetchStoveState());
}, 5000);

return () => clearInterval(intervalId);
}, []);

return (
<div className="App">
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import React from 'react';
import React, {useEffect} from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { store } from './store'
import { Provider } from 'react-redux'
import {fetchHeatingTemperature, fetchMixerTemperature, fetchWaterHeaterTemperature} from "./features/temperature/temepratureSlice";
import {fetchStoveState} from "./features/stoveState/stoveStateSlice";

const root = ReactDOM.createRoot(document.getElementById('root'));

store.dispatch(fetchHeatingTemperature());
store.dispatch(fetchMixerTemperature());
store.dispatch(fetchWaterHeaterTemperature());
store.dispatch(fetchStoveState());

root.render(
<React.StrictMode>
<Provider store={store}>
Expand Down

0 comments on commit c5653c8

Please sign in to comment.