_.delay()-终止计时器

_.delay() - killing the timer

本文关键字:终止 计时器 delay      更新时间:2023-11-08

只是想知道是否有办法终止underscore.js库中_.delay函数中的计时器。它在带注释的源代码中使用setTimeout(),但我不知道具体的方法。

例如:

_.delay(this.functionName, 5000)

如果在3秒时还没有调用,并且我想停止调用functionName,我可以提前终止计时器吗?

var timerId = _.delay(this.functionName, 5000); //save the timerid in a variable
clearTimeout(timerId); //Kill the timer