Created
May 17, 2017 08:30
-
-
Save marcojetson/cc06400ba3473046007372ee03aa782e to your computer and use it in GitHub Desktop.
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
/** | |
* Executes a function with a given interval | |
* @arg {function} fn - Function to execute, | |
* @arg {integer} interval - Interval in milliseconds | |
*/ | |
function poll(fn, interval) { | |
fn(() => setTimeout(() => poll(fn, interval), interval)); | |
} | |
poll(retry => $.get('/status').success(res => res.status === 'pending' && retry())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment