Created
April 14, 2015 19:18
-
-
Save germanotm/6ee68f804860e2e77df0 to your computer and use it in GitHub Desktop.
Coffescript time loop
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
# 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