Skip to content

Instantly share code, notes, and snippets.

@germanotm
Created April 14, 2015 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save germanotm/6ee68f804860e2e77df0 to your computer and use it in GitHub Desktop.
Save germanotm/6ee68f804860e2e77df0 to your computer and use it in GitHub Desktop.
Coffescript time loop
# Classe TimeLoop, execute a function every x miliseconds
#
# @example How o create a loop
# myLoop = new TimeLoop((-> alert("loop"),1000)
# myLoop.start()
#
class window.TimeLoop
constructor: (@function,@miliseconds) ->
# Start loop.
#
start: -> @loop = setInterval @function, @miliseconds
# Stop loop.
#
stop: -> clearInterval(@loop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment