Hi everyone,
I am using:
dash version: 2.13.0
dcc version: 2.12.0
html version: 2.0.14
python: 3.11.4
I have these two inputs that I want to change values of, I’m trying to do it using client-side callbacks. I’m using client-side callback since I need to check every second to update these values, and I think doing it client-side is a better approach.
The problem is that when returning the values outside the setInterval function, the inputs are updated correctly once and it is working. But if I return inside the setInterval function, the updates dont work.
Now that I’m thinking more about it, would manually updating it using javascript be a good option, using document.getElementById(‘id’).value
Here is the client-side js, for simplification I have removed the calculations for these numbers
tracking_satellite: function (is_modal_open) {
if (!is_modal_open) {
const intervalId = localStorage.getItem("intervalId");
window.clearInterval(intervalId)
return ["123", "232"]
}
// here I do some "heavy" calculations,
// so I want to run this once, but continue updating
// the interface using the same callback
intervalId = window.setInterval(function () {
return ["5", "1"]
}, 2000);
localStorage.setItem("intervalId", intervalId);
}
Dash app.py file
clientside_callback(
ClientsideFunction(
namespace='clientside',
function_name='tracking_satellite'
),
[Output("antenna-elevation-value", "value"),
Output("antenna-azimuth-value", "value")
],
Input("track_satellite_offcanvas", "is_open"),
)
Thanks beforehand.