Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

polling interval javascript

var sleep = time => new Promise(resolve => setTimeout(resolve, time))
var poll = (promiseFn, time) => promiseFn().then(
             sleep(time).then(() => poll(promiseFn, time)))

// Greet the World every second
poll(() => new Promise(() => console.log('Hello World!')), 1000)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #polling #interval #javascript
ADD COMMENT
Topic
Name
6+2 =