pollbot
v0.0.3
Published
Pollbot provides tools for periodically performing a task. It's intended for us with APIs and web pages.
Downloads
2
Readme
Pollbot
Pollbot provides tools for periodically performing a task. It's intended for use with APIs and web pages.
Usage
Initialize the pollbot
let Pollbot = require('../pollbot');
let pollbot = new Pollbot();
// Configure the polling
pollbot.loadConfig({
poll_period_ms: 100,
run_immediately: false,
logging_level: 'Debug'
});
// Set up the work to do at each poll
pollbot.setPollingCallback(() => {
console.log("Polling!");
});
// Start polling
pollbot.startPolling(() => {
console.log("Polling has begun!");
});
// Stop polling after a few seconds
setTimeout(() => {
pollbot.stopPolling(() => {
console.log("No more polling will occur!");
});
}, 3000);