Cloudflare HTTP Polling Utilities


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @cloudflare/util-http-poll in KB



Cloudflare HTTP Polling Util


$ yarn add @cloudflare/util-http-poll


import { Poller } from '@cloudflare/util-http-poll';

const pollingFn = () => {
  /* do something fancy */

 The following options can be configured:

  backoffs {Number} - The number of times to backoff and retry
                      after exceeding timeout before quitting
  pollInterval {Number} - The frequency at which to poll
  pollTimeout {Number} - The time after which we stop polling and decide what to do next
  backoffFn: {Function} - Used to decrease the pollInterval frequency
  onError: {Function} - Called when an error is thrown in pollingFn
  haltOnError: {Boolean} - Should stop polling if an error is encountered
const options = { pollTimeout: 30 * 1000 };
const poller = new Poller(pollingFn, options);

// When you're done or unmounting:

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.