下划线的反跳功能 [英] debounce function in underscore

查看:126
本文介绍了下划线的反跳功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用反跳功能为应用程序设置自动注销。我的理解是,如果未使用我的应用程序,则反跳功能将在30秒后触发该功能。我试图阅读有关防抖的文档,并觉得自己已经做了一些确切的事情。我错过了什么吗?还是我的理解是完全错误的?

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);


推荐答案

时间以毫秒为单位,因此您需要做 30 * 1000

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

这篇关于下划线的反跳功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆