Created
September 25, 2019 00:43
-
-
Save alexpilugin/52234fcdbf4f5a7dba2b06666cb1a675 to your computer and use it in GitHub Desktop.
function that recursively invokes itself each 5 seconds
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
//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