Created
May 27, 2011 17:45
-
-
Save jakemcgraw/995762 to your computer and use it in GitHub Desktop.
How to interrupt a timeout
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 pollInterval = 10000, | |
pollTimeout = null; | |
function pollSpots() { | |
printDXSpots(); | |
pollTimeout = window.setTimeout(pollSpots, pollInterval); | |
} | |
// ... later ... | |
function forcePollSpots() { | |
if (pollTimeout) { | |
window.clearTimeout(pollTimeout); | |
} | |
printDXSpots(); | |
pollTimeout = window.setTimeout(pollSpots, pollInterval); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment