m-wrzr / streamlit-searchbox

Streamlit searchbox that dynamically updates and provides a list of suggestions based on a provided function
MIT License
253 stars 33 forks source link

Add `reset_function` callback option #58

Closed hoggatt closed 2 months ago

hoggatt commented 2 months ago

Add a callback function that can be run in the case of a reset.

This is useful if you want to change some value in your app in the case of a reset. Pulling from my fork that, unfortunately, I have so it won't let me make a pull request.

To the main function add this argument: reset_function: Callable[[], None] = None,

With this doc string:

reset_function (Callable[[], None], optional):
    Function that is called after the user has reset the combobox. Defaults to None.

Then this needs to be in the if interaction == "reset": block, before the return:

if reset_function is not None:
    reset_function()
hoggatt commented 2 months ago

Here is the docstring in the readme:


reset_function: Callable[[], None] = None

Function that will be called when the combobox is reset.

m-wrzr commented 2 months ago

Thanks for the input! I'll add it to the next version 👍 https://github.com/m-wrzr/streamlit-searchbox/pull/59