Created
April 12, 2016 08:53
-
-
Save slavone/edf62dc3874d28a89adc38b2837f2237 to your computer and use it in GitHub Desktop.
Basic ajax poller in .coffee
This file contains hidden or 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
@AjaxPoller = (args) -> | |
this.controllerUrl = args['controllerUrl'] | |
this.pollBody = args['pollBody'] | |
this.pollWhile = args['pollWhile'] | |
this.interval = args['interval'] | |
this.startPolling = () -> | |
that = this | |
$.ajax | |
url: that.controllerUrl | |
dataType: 'json' | |
success: (data) -> | |
that.pollBody(data) | |
complete: -> | |
if that.pollWhile() | |
setTimeout(that.startPolling.bind(that), that.interval); | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment