How to callback dcc.Loading for a process run?

Hi in my application, I have a button, a default, loading, error and output screen in my layout. I toggle between these 4 screens based on my button click. I need something like:

  • if button is not clicked: default screen
  • if clicked: dcc.Loading full screen
  • once process is done: output screen
  • if error during process: error screen

Please note I can’t use time.sleep(n) because the process time is variable. The current issue I’m facing is I have a callback written but if I return dcc.Loading I can’t continue with the process. Please help!