I have an app that needs to do some work (read from a database etc.) on page load. I saw that it is possible to do this by assigning a function to app.layout
(see Live Updates | Dash for Python Documentation | Plotly).
Now, my problem is that I don’t have a vanilla function for reading from a DB, I have a coroutine:
import db_util
import dash_table
async def render_layout():
data = await db_util.get_config_data()
return dash_table.DataTable(id="my-data-table", columns=..., data=data)
app.layout = render_layout
Problem is, when I do this I get
TypeError: argument of type ‘coroutine’ is not iterable
Unfortunately, I cannot change db_util, as it’s not my own code. Is there a plan to support coroutines for app.layout? Or does anyone see a way around this that I might not have thought about, yet?