72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly<style scoped>
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly/* custom styles for this example */
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly#demo .output {margin-bottom:1em; padding:10px; border:1px solid #D9D9D9;}
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly<div class="intro">
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly <p>DataSource's Pollable extension enables polling functionality on all your DataSource instances.</p>
819e90d415ed17d59af3a247b2ad9d6feb0c21b5Luke Smith<div class="example yui3-skin-sam">
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly {{>datasource-polling-source}}
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly<p>Include the `datasource-pollable` extension in your `Y.use()` statement to add the `setInterval()`, `clearInterval()`, and `clearAllInterval()` methods to all your DataSource instances.</p>
72378c4b11f0468874fbad14749246d2ae564474Jenny DonnellyYUI().use("datasource-function", "datasource-polling", function(Y) {
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly var myFunction = function() {
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly return new Date();
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly myDataSource = new Y.DataSource.Function({source:myFunction}),
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly success: function(e){
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly Y.one("#demo_output_polling")
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly .setContent("At the tone the time will be: " +
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly failure: function(e){
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly Y.one("#demo_output_polling")
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly .setContent("Could not retrieve data: " + e.error.message);
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly id = myDataSource.setInterval(1000, request); // Starts polling
72378c4b11f0468874fbad14749246d2ae564474Jenny Donnelly myDataSource.clearInterval(id); // Ends polling