Skip to content

Instantly share code, notes, and snippets.

@Akamaozu
Created November 17, 2016 21:57
Show Gist options
  • Save Akamaozu/631f097e76585adf331b87106e863155 to your computer and use it in GitHub Desktop.
Save Akamaozu/631f097e76585adf331b87106e863155 to your computer and use it in GitHub Desktop.
Make sure a callback is triggered only once
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