Hi All,
I have a query before i entirely break my app, the question relates to the dcc.Store functionality.
Currently I have some nasty callbacks which run through mass lines of IF statements due to the multiple inputs - for example this is how one of my callbacks inputs and outputs looks:
@callback(
Output("g1", "children"),
Output("g1", "className"),
Output("g2", "children"),
Output("g2", "className"),
Output("gcol", "className"),
Output("gcol2", "className"),
Input("name", "value"),
Input("name2", "value"),
Input("v_name", "value"),
Input("v_name2", "value"),
Input("l_name", "value"),
Input("l_name2", "value"),
Input("t", "value"),
Input("t2", "value"),
)
Now this callback does if checks on every single combination of those inputs and this results in a callback that is over 2000 lines long - which is ridiculous.
I want to refactor this and first question is: Is dcc.Store the right/best way to refactor it?
Secondly the idea for the dcc.Store utilization would be the following:
- Create a dcc.Store for v_name which makes use of the name Dataframe
- Create a dcc.Store for l_name which makes use of a dataframe created out of step 1 above
- Create a dcc.Store for t which makes use of a dataframe created out of step 2 above
- replace all inputs on the above callback with the dataframe created out of step 3 above therefore eliminating all IF loop combos on the callback and taking it from 2000 lines to roughly 20-30
Can someone advise if this is best practise/the right way to do it and also could you perhaps provide a simple example of how to move from step 1 to step 2 - would be much appreciated!