Inventables Community Forum

Bug: There should be a short delay before calling the executor function when changing a range value

If you slide the selector for a range value, the executor function is called continuously, even though it’s going to be re-called again and overwrite the output of the previous call. This is problematic for any app that makes a remote call, since a user can effectively DOS the remote server by slowly dragging the range selector around.

Please add a short delay before calling executor(), like this pattern that is often used in web apps (pseudo-JavaScript):

var executorTimer = null;

range.onchange = function () {
  clearTimeout( executorTimer );
  executorTimer = setTimeout( executor, 250 );
1 Like

This is an old post, but I used it to solve the issue I’m having. I rename the executor function to executor2 and then create an executor timeout like what you show and it gives the intended effect:

var timeout = null;

var executor = function(args, success, failure) {
      timeout = setTimeout(function () {
        executor2(args, success, failure);
      }, 500);

var executor2 = function(args, success, failure) {
     // Normal code here ...

So the code above gives me a half second delay between changing a range value and when it actually renders. The clearTimeout is important in that it only keeps the latest timeout callback.

Thanks @EthanKinney, that worked really well.