Skip to content

Instantly share code, notes, and snippets.

@noelrocha
Created April 9, 2013 21:30
Show Gist options
  • Save noelrocha/5349581 to your computer and use it in GitHub Desktop.
Save noelrocha/5349581 to your computer and use it in GitHub Desktop.
Abstract Poller in coffee script
class Poller
constructor: (name) ->
console.log "[#{name}]"
@name = name
@failed = 0
@interval = 5000
@run = true
timeoutID = null
init: () ->
#console.log "[#{@name}] init"
timeoutID = setTimeout(@process, @interval)
stop: () ->
console.log "[#{@name}] stop"
run = false
window.clearTimeout(timeoutID)
process: () ->
console.log "[Poller.process] should be implemented"
errorHandler: () ->
console.log "[Poller.errorHandler] should be implemented"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment