Last active
August 2, 2017 20:01
-
-
Save joshuaebowling/d93b4344ee8f54165a748549f66b8410 to your computer and use it in GitHub Desktop.
Wait for it... a time-of-no-change based throttling pattern
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 | |
WAIT_TIMER = 1750, // in MS | |
waitForItTimer, | |
waitForIt, whatYoureWaitingToInvoke; | |
whatYoureWaitingToInvoke = function _whatYoureWaitingToInvoke() { | |
alert(`what you're waiting for!!`); | |
}; | |
waitForIt = function _waitForIt() { | |
window.clearTimeout(waitForItTimer); | |
waitForItTimer = setTimeout(() => { | |
whatYoureWaitingToInvoke(); | |
}, WAIT_TIMER); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment