144-bytes lightweight JavaScript polling library!
This library can be used to setup a run function in specified intervals that can also be used for polling the server for new data. one of the advantages of this library is to avoid the evil behaviour of
setIntervalwhich is a function interval don't wait for the former function to finish before starting which results in bunch of functions that has not been executed.
- AJAX to pull data repeatedly
- Run a function in intervals etc.
holler( func, intervalMs=1000 );
funcis the function to run.
intervalMsis the intervals to runfuncin milliseconds, defaults:1000.
holler( function(){
fetch( 'http://www.awesome-site.com/api/feeds', myOptions )
.then(function( data ) {
// Here you get the data to modify as you please
})
.catch(function( error ) {
// If there is any error you will catch them here
});
} , 2000 ); // 2000ms = 2 secondsThanks - Oyedele Hammed