Get help from the marimo community

B
Björn
Offline, last seen 2 months ago
Joined January 19, 2025
Can the data for a download button be "computed when needed", i.e., only once the user clicks the button? Currently I have
Plain Text
mo.download(
        data=expensive_function_generating_the_data(),
    )

which means expensive_function_generating_the_data is called already when the button is created. Instead, I'd prefer something like
Plain Text
mo.download(
        data=expensive_function_generating_the_data,
    )

where the function would only generate / provide the data when the button is actually clicked, as not the output expensive_function_generating_the_data() is passed to the data keyword, but the function handle expensive_function_generating_the_data.

I know that this currently does not match the signature of mo.download, but is there a way to work around this?
2 comments
M
B