0.0.3 • Published 7 years ago

pollbot v0.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

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);