jenny
jenny

Reputation: 277

debounce function in underscore

I am trying to use the debounce function for setting automatic logout for my application. My understanding is that debounce function will fire the function after the 30 seconds if my application not used. I tried to read the documentation of debounce and feel like I have done the exact something. Am i missing out something? or Is my understanding totally wrong?

var logout_debounce = _.debounce(debounceHandler, 30);
function debounceHandler() {
    location.reload();
}

$("body").on("mousemove", logout_debounce);

Upvotes: 0

Views: 2540

Answers (2)

nanobar
nanobar

Reputation: 66355

The time is in milliseconds so you would need to do 30 * 1000

Upvotes: 2

Atlas
Atlas

Reputation: 241

That 30 is milliseconds, if you want it to be fired after 30 seconds ; you must use 30*1000 = 30000

Upvotes: 1

Related Questions