Created
July 27, 2017 12:24
-
-
Save electerious/e4fef1a1355bdf3505cdc24da1701486 to your computer and use it in GitHub Desktop.
Loop an async function with a delay
This file contains hidden or 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
const loop = (fn, delay) => { | |
const next = () => setTimeout( | |
() => loop(fn, delay), | |
delay | |
) | |
fn(next) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: