diff -r 322d0feea350 -r 89ef5ed3c48b src/cm/media/js/lib/yui/yui_3.10.3/docs/datasource/datasource-polling.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.10.3/docs/datasource/datasource-polling.html Tue Jul 16 14:29:46 2013 +0200 @@ -0,0 +1,238 @@ + + + + + Example: DataSource with Polling + + + + + + + + + + +
+
+

+
+ + +

Example: DataSource with Polling

+
+
+
+
+ +
+

DataSource's Pollable extension enables polling functionality on all your DataSource instances.

+
+ +
+
+
Poll every second for current time:
+ + +
+
+ + + +
+ +

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}),
+        request = {
+            callback: {
+                success: function(e){
+                    Y.one("#demo_output_polling")
+                     .setHTML("At the tone the time will be: " +
+                                Y.dump(e.response.results[0].toString()));
+                },
+                failure: function(e){
+                    Y.one("#demo_output_polling")
+                     .setHTML("Could not retrieve data: " + e.error.message);
+                }
+            }
+        },
+        id = myDataSource.setInterval(1000, request); // Starts polling
+
+        myDataSource.clearInterval(id); // Ends polling
+});
+ +
+
+
+ +
+ +
+
+
+ + + + + + + + + + +