Created
November 17, 2016 21:57
-
-
Save Akamaozu/631f097e76585adf331b87106e863155 to your computer and use it in GitHub Desktop.
Make sure a callback is triggered only once
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
function exclusive_execute( real_callback ){ | |
var triggered_callback = false; | |
return function(){ | |
if( triggered_callback ) return; | |
triggered_callback = true; | |
real_callback(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment