Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Poll = function(pollFunction, intervalTime) {
- var intervalId = null;
- this.start = function(newPollFunction, newIntervalTime) {
- pollFunction = newPollFunction || pollFunction;
- intervalTime = newIntervalTime || intervalTime;
- if ( intervalId ) {
- this.stop();
- }
- intervalId = setInterval(pollFunction, intervalTime);
- };
- this.stop = function() {
- clearInterval(intervalId);
- };
- };
- var p = new Poll(function() { console.log("hi!"); }, 1000);
- p.start();
- setTimeout(function() { p.stop();}, 5000);
- var p = new Poll(sendRequest, 3000);
- p.start();
- dojo.provide("Poll");
- dojo.declare("Poll", null, {
- intervalId: null,
- pollFunction: null,
- intervalTime: null,
- constructor: function(newPollFunction, newIntervalTime) {
- this.pollFunction = newPollFunction;
- this.intervalTime = newIntervalTime;
- },
- start: function(newPollFunction, newIntervalTime) {
- this.pollFunction = newPollFunction || this.pollFunction;
- this.intervalTime = newIntervalTime || this.intervalTime;
- this.stop();
- this.intervalId = setInterval(this.pollFunction, this.intervalTime);
- },
- stop: function() {
- clearInterval(this.intervalId);
- }
- });
- var p = new Poll(function() {console.log("hi");}, 250);
- p.start();
- setTimeout(dojo.hitch(p, p.stop), 1000);
- yourGrid.on('dgrid-refresh-complete', function(event) {
- //Ajax request fireing every 3 sec
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement