posit-dev / py-shinywidgets

Render ipywidgets inside a PyShiny app
MIT License
41 stars 2 forks source link

Provide a way to throttle/debounce `reactive_read()` invalidation #95

Open cpsievert opened 1 year ago

cpsievert commented 1 year ago

Perhaps using the "recommended" ipywidgets implementations https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Events.html#throttling

jcheng5 commented 1 year ago

Maybe not the most convenient, but I posted throttle and debounce decorators here: https://github.com/rstudio/py-shiny/issues/564

So instead of reactive_read(x, "foo") you could do:

@debounce(2)
@reactive.Calc
debounced_x_foo():
    return reactive_read(x, "foo")

and then refer to debounced_x_foo() everywhere you would've done reactive_read(x, "foo").