I found this approach to replace content and it works fine:
viewer = st.image(something)
# some callback, e.g. MQTT
def func(something_else):
viewer.image(something_else)
But I could not find anything about the return values of e.g. st.image
or st.line_chart
and the logic behind this in the doc.
Why does it work?
Unlike interactive elements (like button, text_input, etc.) which returns the value as input by the user, static elements like image, video, etc. just return the (placeholder) container in which the object is placed.
Because of this reason, you’re able to use the container’s reference to reset the object.
To understand how it works, check st.empty()