Just curious if there is a way to kill the timer in the _.delay
function in the underscore.js
library. It is using setTimeout()
in the annotated source but I can't figure out the actual way to do this.
An example would be:
_.delay(this.functionName, 5000)
If this has not been called at 3 seconds and I want to stop functionName
being called, can I kill the timer early?
var timerId = _.delay(this.functionName, 5000); //save the timerid in a variable
clearTimeout(timerId); //Kill the timer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With