DataSource Utility: DataSource with Polling
+ +
+
+
+
+ DataSource's Pollable extension enables polling functionality on all your DataSource instances.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Include the datasource-pollable extension in your Y.use() statement to add the setInterval(), clearInterval(), and clearAllInterval() methods to all your DataSource instances.
YUI().use("datasource-function", "datasource-polling", function(Y) { var myFunction = function() { return new Date(); }, myDataSource = new Y.DataSource.Function({source:myFunction}), callback = { success: function(e){ alert("At the tone the time will be: " + e.response.results[0]); }, failure: function(e){ alert("Could not retrieve data: " + e.error.message); } }, id = myDataSource.setInterval(1000, null,callback); // Starts polling myDataSource.clearInterval(id); // Ends polling });
YUI().use("datasource-function", "datasource-polling", function(Y) { + var myFunction = function() { + return new Date(); + }, + myDataSource = new Y.DataSource.Function({source:myFunction}), + callback = { + success: function(e){ + alert("At the tone the time will be: " + e.response.results[0]); + }, + failure: function(e){ + alert("Could not retrieve data: " + e.error.message); + } + }, + id = myDataSource.setInterval(1000, null,callback); // Starts polling + + myDataSource.clearInterval(id); // Ends polling +});

