Skip to content

Instantly share code, notes, and snippets.

@alexpilugin
Created September 25, 2019 00:43
Show Gist options
  • Save alexpilugin/52234fcdbf4f5a7dba2b06666cb1a675 to your computer and use it in GitHub Desktop.
Save alexpilugin/52234fcdbf4f5a7dba2b06666cb1a675 to your computer and use it in GitHub Desktop.
function that recursively invokes itself each 5 seconds
//Make a function that recursively invokes itself at the end on a timer
//This immediately invokes my_func, and then recursively invokes it at the end of the function after a 5 second delay.
(function my_func() {
// your code
setTimeout( my_func, 5000 );
})();
(function my_func() {
// your code
if( some_criteria_is_met ) {
setTimeout( my_func, 5000 );
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment