How to periodically update a component?

I want to display a status widget that gets its value from some external server (say, WebSocket).
I wouldnā€™t want to rerun the streamlit app to update the status widget, rather Iā€™d want it to update itself every second on its own (possibly on the frontend).
Ideally, the component would look ā€œorganicā€, in the sense that it would respect the current theme set in streamlit.
Whatā€™s the easiest way of achieving that?

Hi @Michael_Litvin

You can make use of the time module (namely the sleep method to add a delay) when iterating through time. Make sure to first define a placeholder with st.empty() and for each iteration you can display an update of the component of interest by assigning it to the placeholder.

Please see this blog (How to build a real-time live dashboard with Streamlit) particularly section 5 in order to see this in action.

Hope this helps!