Skip to content

Instantly share code, notes, and snippets.

@cpuguy83
Last active December 24, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cpuguy83/6884647 to your computer and use it in GitHub Desktop.
Save cpuguy83/6884647 to your computer and use it in GitHub Desktop.
Poll returns immediately after the page is loaded for some reason... any ideas?
@Poller =
delay: (ms, func) -> setTimeout func, ms
poll: (url,time)->
@schedulePoll(url, time)
$.getScript(url)
schedulePoll: (url, time=30000) ->
poller = @delay(time, =>@poll(url, time))
$(document).on 'page:fetch', =>
clearTimeout(poller)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment