Skip to content

Instantly share code, notes, and snippets.

@rwjblue
Forked from cpuguy83/poller.coffee
Last active December 25, 2015 00:09
Show Gist options
  • Save rwjblue/6885116 to your computer and use it in GitHub Desktop.
Save rwjblue/6885116 to your computer and use it in GitHub Desktop.
@Poller =
delay: (ms, func) -> setTimeout func, ms
poll: (url,time)->
poller = schedulePoll(url, time)
$.ajax
url: url,
dataType: 'script'
$(document).on 'page:fetch', =>
clearTimeout(poller)
schedulePoll: (url, time=30000) ->
@delay(time, =>@poll(url, time))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment