Last active
August 17, 2017 15:40
-
-
Save mattsouth/055a6654e2e14ba0b3c1b8d806211c1c to your computer and use it in GitHub Desktop.
In your REPL of choice you can create a ticker and then start and stop it at will.
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
class exports.Ticker | |
constructor: (timeout) -> | |
@timeout = timeout || 1000 | |
_nextTick: => | |
@tick = setTimeout(@_nextTick, @timeout) | |
console.log 'tick' | |
start: -> | |
@_nextTick() | |
stop: -> | |
clearTimeout @tick | |
console.log 'stopped' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similarly, in both the coffee and node REPL you can set a ticking ticker equal to undefined and it will continue ticking, though again, you will no longer be able to stop it.