plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.16k stars 2.04k forks source link

Add outputs_list to clientside callback_context #1610

Open pmkroeker opened 3 years ago

pmkroeker commented 3 years ago

1240 added good things to the clientside callback_context. The one missing part that the serverside version has is the outputs_list, this is useful when needing to output things to Outputs that have been bound using the Pattern-matching syntax.

Is your feature request related to a problem? Please describe. When using clientside callbacks, if the outputs are set using pattern matching (ALL) there is no way of knowing how many items should be returned by the callback function.

Describe the solution you'd like dash_clientside.callback_context includes an outputs_list like the server version has.

Describe alternatives you've considered Can check how many exist using things like document.querySelector or by passing in values from state.

KS-HTK commented 11 months ago

Just ran into this exact problem. If the output of the callback is an non Array object this is not a problem as it will get assigned to all outputs. But if the callback returns an Array Dash will try assigning the items to the outputs instead of assigning the full Array to each of the outputs. Wrapping the Array into another Array does not help as the first output gets the Array but any further output gets an empty Array. So we need a way to know how many outputs there are. Currently I use a State to get the amount of Outputs, but I think the callback_context.outputs_list would be better. Also there is no documentation that I could find on the dash_clientside.callback_context.