I have a loading dialog that prompts to the user while the data is being loaded. I can easily show it when the user clicks a button, but I also need an easy way to hide it when the data is loaded.
I was thinking that I nice way to address it it would be to have a callback that listens to an event (a signal) and hides the dialog when this event is received. The last piece I need to finish my puzzle it would be to have a way to trigger a Dash event that a callback can listen to directly from my Python code.
I have been looking in the documentation and in the forums, but I havenāt found any way to trigger this kind of events.
As a workaround, I could use a hidden div and use it as a trigger for hiding the dialog. But the other way looks like a more convenient way to me; moreover, I think the potential of Dash could be enlarger provided with this capability.
Another alternative is to build your own component (Dash Documentation & User Guide | Plotly) that provides properties / attributes that represent the different stages of this component (āloadingā, ādone_loadingā, etc).
Going back to the topic thread, would you be willing to merge a pull request that allows to trigger dash Events from python code? I think that it isnāt a big work, am I right?
Right now, Dash uses regular HTTP requests, not websockets, so the event has to āoriginateā from the browser. So, even if you were to able to call the Python function in Python, we donāt have a way to propagate that update to the dash front-end. In the future, if we ever add websocket support, this would be possible.
possible, server side events might be of interest here. this bypasses the need for websockets, allowing for the existing mechanisms in place to provide pushing to the browser.
No progress on this, and this isnāt currently scheduled for the next few months. Weāre focusing on a few other things for the short term: Projects Ā· plotly Ā· GitHub
I see, well, fingers crossed to see it at some point. Still, the changes over the past few months have been great already!
And, follow-up question: I could try to workaround using events, because I donāt want to handle too many inputs. What are the events associated with dcc.Dropdown and dcc.Input? I only want to register āuser makes a changeā or āuser interactsā. Is there a doc somewhere?
There isnāt really. I"m actually trying to move away from Event, as it isnāt quite the right abstraction (itās not possible to tell _which_event was fired, which makes it unuseful and confusing). Instead, I recommend using Input to trigger your change. If you donāt want to handle as many inputs in the callback, just place them at the end and use *args:
If I understood the comment by @_jf correctly, it should somehow be possible to use Server-Sent-Events to āLive-Updateā the Dash-Dashboard, right? This would be pretty helpful, as I currently have a Prediction-Service in the back-end which I want to use to publish new predictions.
I had a look at the Medium-Post, but I am not sure if and how this could be integrated within Dash? Do you guys know any further resources on how to implement SSE such that the Dash-Interface is getting updates from the prediction-service?