July 2011
Intermediate to advanced
276 pages
5h 11m
English
Review the previous recipe; all we will be adding here is a periodic refresh that updates the data.
Creating a periodical object has a simple syntax that takes a mandatory first argument of how many milliseconds after which to repeat the function call.
// periodically (every 10 seconds) refresh the stock ticker
var refresh_ticker = function() { myJax.send(); };
var my_ticker_refresh = refresh_ticker.periodical(10*1000);
// delay (once after 30 seconds) stop the ticker refresh!
var stop_ticker_refresh = function(){ clearInterval(my_ticker_refresh); };
stop_ticker_refresh.delay(30*1000);
Stopping the function call requires us to have saved the result of the periodical instantiation. In our recipe, ...