Skip to content

Instantly share code, notes, and snippets.

@Shamaoke
Created February 24, 2012 15:36
Show Gist options
  • Save Shamaoke/1901657 to your computer and use it in GitHub Desktop.
Save Shamaoke/1901657 to your computer and use it in GitHub Desktop.
Using setInterval
class Example
constructor: (@counter, @final, @id = null) ->
prepare: (meth) -> @id = setInterval(meth, 1000); return
count: =>
console.log @counter
@counter += 1
clearInterval @id if @counter is @final
return
start: -> @prepare @count; return
@new: -> new @ 0, 10
Example.new().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment