Skip to content

Adding debounce to self.param.update #984

Open

Description

@ahuang11

I would like a built-in mechanism in the self.param.update method (or similar) that supports debouncing. https://www.geeksforgeeks.org/debouncing-in-javascript/

Example:

  1. The code waits for 2 seconds before showing the loading icon.
  2. If the process completes or the event resolves within those 2 seconds, the icon is never shown.
  3. If the process doesn't complete, the icon appears after the delay, signaling that something is still loading.

This feature could be particularly useful for applications with frequent, rapid user interactions that trigger parameter updates (e.g., sliders or live data streams). It would improve the UX by removing flicker.

Use case would be linking widgets with self.state.param.busy, but at the current moment it could cause flickering:
holoviz/lumen#783 (comment)

I think it would be implemented here https://github.com/holoviz/param/blob/main/param/parameterized.py#L2297-L2357

Activity

  1. hoxbro commented on Dec 4, 2024

    @hoxbro
    Member

    I don't think this functionality should live in Param. I do think we should have some way to make the busy toggle not flicker on/off with a debounce, though I think this functionality should live in Panel.

  2. maximlt commented on Feb 11, 2025

    @maximlt
    Member

    I'm not sure what the right solution is for the Panel issue reported here.

    I think however that adding debouncing to Param could be a good fit as Param supports async callbacks. I'm not entirely sure why the suggestion is for self.param.update, I'd see it more as a new keyword added to .param.watch.

    import panel as pn
    
    w_search = pn.widgets.TextInput(name='Search ...')
    p_resuls = pn.MarkDown()
    
    async def expensive_search(event):
        p_resuls.value = await db.query(...)
    
    w_search.param.watch(expensive_search, 'value_input', debounce=3000)
    pn.Column(w_search, p_resuls).servable()

    @ahuang11 I wouldn't be surprised if that's a feature that was already implemented somehow in Panel for its internal needs. If that's really the case, that could motivate even more so implementing it in Param (many of the features of Param were first implemented in Panel).

    I think it would be implemented here https://github.com/holoviz/param/blob/main/param/parameterized.py#L2297-L2357

    @ahuang11 this link no longer points to the right lines.

  3. added
    type-feature
    status: discussion
    on Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: discussiontype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions