Created
October 10, 2016 15:50
-
-
Save rjmacarthy/f509ff0b2e10cc52a9e3309356df75ef to your computer and use it in GitHub Desktop.
Interval without setTimeout
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
import { random, delay } from 'lodash'; | |
export const interval = (fn) => { | |
fn(); | |
delay(() => { interval(fn); }, randomNumber()); | |
}; | |
var randomNumber = () => { | |
return random(1000, 10000) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment