Skip to content

Idea: Debounce and throttle options for observing traits #663

Open
@maartenbreddels

Description

@maartenbreddels

Two use cases:

  1. Using interact or a slider that causes something to execute which say takes ~100 ms to complete, you don't want events to be delivered all the time, but you may want to update it say every 250 ms, when a slider is changing value.
  2. I'm using bqplot and listening to a change in the min value of one of the axes. Only when it didn't change for say 500msec, I expect the user to be done with zooming and panning and will start a heavy computation to rebuild the figure.

If this is done on the client side (js), this will also lead to less traffic/events.

I can imaging something like this

interact(f, x=10, throttle=250);

For the bqplot use case

scale_x.observe(f, "xmin", debounce=500)

See here for a visual explaination:
http://benalman.com/projects/jquery-throttle-debounce-plugin/

throttle and debounced functions are also available in underscore

Having them in link and js(d)link could also be useful (say when a widget would make a ajax request)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions