handle multiple Outputs in app.callback
See original GitHub issueIt would be nice to have the ability to update multiple outputs at once by specifying a list of Outputs and returning a tuple with the same number of outputs like in
@app.callback(
[Output('label1', 'children'),
Output('label2', 'children'),
],
[Input('dropdown', 'value'),
])
def cb_test_multi(value):
# some very complex calculation to be triggered only once when 'dropdown' changes
...
# result of calculation need to be pushed partly on 'label1' and partly on 'label2'
return "Hello", value
This would allow simplifying otherwise complex flow to update multiple components based on one change.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:54
- Comments:20 (8 by maintainers)
Top Results From Across the Web
Multiple outputs in Dash - Now Available!
Use a list/tuple of Output as output in callbacks. Return a tuple/list of value from the callbacks. The returned list must have the...
Read more >Is there a better way to perform multiple output with Dash by ...
As we can see in Interactivity part of Getting started, one callback function can accept multiple inputs but always has single ...
Read more >The Dash Callback - Input, Output, State, and more - YouTube
The Callback is the most important element in Dash. You need to know it so you can create interactive dashboard apps.
Read more >Learn about the Callback first if you are starting to learn Dash ...
The callback is what allows you to create interactive web apps and ... file) 12:26 - Multiple Outputs Inputs (radio-slider file) 17:03 ...
Read more >Basic Dash Callbacks - angela1c.com
Multiple Inputs and Outputs · A dash app can have multiple inputs. · Any “Output” can have multiple “Input” components. · More than...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Makes sense to me! The
app.callbacksyntax and the HTTP API were designed in such a way to allow something like this. I left this out of the initial release because I thought that it would cause some confusion among users (mainly: when do you use multiple callbacks vs multiple outputs) and I wanted to keep the surface area as small as possible for the initial release. There are some other alternatives to “sharing computations” among multiple callbacks (see https://plot.ly/dash/sharing-data-between-callbacks) but none of them are as simple as this proposal.By introducing multiple outputs, there will be 2 ways to do the same thing: 2 outputs in a single callback vs 2 callbacks with a single output. It really only makes to use multiple outputs if the callback is expensive.
I can also imagine that some users will end up using multiple outputs in cases where two callbacks that executed in parallel would end up resulting in faster UI updates, for example:
In any case, I’m 👍 with this now. It’ll be a bit of work to implement, so if you would like to see this work please 👍 this issue. If you or your company needs this work expedited and can sponsor development, please reach out: https://plot.ly/products/consulting-and-oem/
It hasn’t been, but it’s still a good idea and I think we’ll end up implementing before the end of the year.
What I’ve done in these types of situations is create a look that generates these functions: