Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! ✅Check out the new docs.

Handle first callback on App start

Hi, I am a beginner with Dash and it’s really awesome. I was hoping to find the solution for the automatic firing of the callbacks on app start.
I have made an app which start with user input and I don’t want to fire the initial callbacks. Right now I am handling it by comparing properties of elements like.

if n_click is None:
    "means initial firing"

It’s easy with a button but it get harder with other components. I want to know the best way I can handle this for a lot of callbacks.

Something like a single reference variable which change after initial callback will also do.

1 Like

Checking if the property is None should work for all properties (unless you’ve initialized them to something different). You can also prevent updates by raising dash.exceptions.PreventUpdate().

So, your code would be like:

if value is None:
   raise dash.exceptions.PreventUpdate()
2 Likes