How to implement a global mechanism to display messages to user

I have a pretty complex layout with dozens of components and callbacks. Some of the callbacks make complex calculations from data retrieved from a remote server. The data can be very unclean, so I’d like to be able to show users some errors and warnings that I generate within my code.

Can anyone think of a way to model this? Yes, I know I could use dbc.Alert for the display, but what is blocking me is how I could do this without having to have one alert component for each callback (on the basis that you can’t have multiple callbacks with the same output).

I’m completely stumped, and yet something tells me it must be possible…

The output issue can be overcome by using the MultiplexerTransform from dash-extensions,

For displaying the status messages, I would recommend the notifications system from dash mantine components,

4 Likes

Thanks for that. For some reason your dash-extensions never made it into my search results…

Couple of questions:

  • does it support the latest DASH version?
  • will this work even in situations where layout components are dynamically added to the page? (I have a set of tabs whose content is only loaded when the user clicks on them - something I had to do a while back to speed up loading of the page)
  1. Yes, the most recent version(s) of dash-extensions targets Dash 2.x, but I haven’t added support for long callbacks
  2. I believe it should. You might need to do a few adjustments to get dcc.Loading components to work properly though

I read that info regarding dcc.Loading. I assume this would only apply to dcc.Loading that wrap elements that are the output target of multiple callbacks? Or will it apply to all of them?

Only the ones that are the output target of multiple callbacks (other callbacks/component structures remain unchanged).