Callbacks included in all-in-one components are registered when the component’s class is loaded, usually this is done when starting the server. One problem of this approach is that you can’t pass instance variables to your callbacks. This is relevant if you need the callbacks to use configuration details that were set by the user when adding the all-in-one component to there dashboard:
my_aio_comp = MyAIO(aio_id="cool_component", custom_config=...)
There are some workaround, e.g. the dash pages show how to use a Redis database to store a dataframe. Also, when the configuration details are static like a string, you can add a dcc.Store
to the AIO component, store the configuration details in that store and add it to the callbacks.
My issue here is that I have not been able to find such a workaround for Python object, e.g. a function handle.
I have a component that is a Dash interface for some API. I want to allow the user to pass a custom response parser to the AIO component that I can call before storing the response of the API in a dcc.Store
and hand it back to the user. The raw output of the API can become to large to store in the store, however there is no general way to parse the API response as that will depend on what input the user provides. Does anyone have suggestions how to deal with this?
I have seen the possibility to put the callbacks inside a method and call that method in the __init__()
method. Could this be a solution to pass variables to the AIO component by the user? If so, what happens when the user initialize multiple copies of the AIO component, will the same callbacks be registered multiple times?