Created
June 22, 2013 17:23
-
-
Save sammachin/5841675 to your computer and use it in GitHub Desktop.
Rate limiting in javascript, ideal for things like watch location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timer = false; | |
function doSomething(){ | |
if (timer == false){ | |
console.log("DOING SOMETHING"); | |
timer = true; | |
console.log("Timer is set") | |
setTimeout(function(){timer = false; | |
console.log("Timer is clear") | |
},10000); | |
} | |
else{ | |
console.log("Denied by LIMIT") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment