Skip to content

Instantly share code, notes, and snippets.

@mattsouth
Last active August 17, 2017 15:40
Show Gist options
  • Save mattsouth/055a6654e2e14ba0b3c1b8d806211c1c to your computer and use it in GitHub Desktop.
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.
class exports.Ticker
constructor: (timeout) ->
@timeout = timeout || 1000
_nextTick: =>
@tick = setTimeout(@_nextTick, @timeout)
console.log 'tick'
start: ->
@_nextTick()
stop: ->
clearTimeout @tick
console.log 'stopped'
@mattsouth
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment