datasource-polling-debug.js revision 31557e8bce12ddd0d89b20190e50a0141e9491ba
/**
* Extends DataSource with polling functionality.
*
* @module datasource
* @submodule datasource-polling
*/
/**
* Adds polling to the YUI DataSource utility.
* @class Pollable
* @extends DataSource.Local
*/
Pollable = function() {};
/**
* @property _intervals
* @description Hash of polling interval IDs that have been enabled,
* stored here to be able to clear all intervals.
* @private
*/
_intervals: null,
/**
* Sets up a polling mechanism to send requests at set intervals and forward
* responses to given callback.
*
* @method setInterval
* @param msec {Number} Length of interval in milliseconds.
* @param request {Object} Request object.
* @param callback {Object} An object literal with the following properties:
* <dl>
* <dt><code>success</code></dt>
* <dd>The function to call when the data is ready.</dd>
* <dt><code>failure</code></dt>
* <dd>The function to call upon a response failure condition.</dd>
* <dt><code>scope</code></dt>
* <dd>The object to serve as the scope for the success and failure handlers.</dd>
* <dt><code>argument</code></dt>
* <dd>Arbitrary data that will be passed back to the success and failure handlers.</dd>
* </dl>
* @return {Number} Interval ID.
*/
Y.log("Enabling polling to live data for \"" + Y.dump(request) + "\" at interval " + msec, "info", this.toString());
var self = this,
id = setInterval(function() {
//self._makeConnection(request, callback);
}, msec);
if(!this._intervals) {
this._intervals = {};
}
return id;
}
else {
Y.log("Could not enable polling to live data for \"" + Y.dump(request) + "\" at interval " + msec, "info", this.toString());
}
},
/**
* Disables polling mechanism associated with the given interval ID.
*
* @method clearInterval
* @param id {Number} Interval ID.
*/
clearInterval: function(id) {
// Validate
// Clear from tracker
delete this._intervals[id];
// Clear the interval
}
},
/**
* Clears all intervals.
*
* @method clearAllIntervals
*/
clearAllIntervals: function() {
}
};