🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

poll-js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poll-js

Wrap async requests and make them repeatable

0.0.3
latest
Source
npm
Version published
Weekly downloads
300
-22.48%
Maintainers
1
Weekly downloads
 
Created
Source

poll-js Build Status npm version

Installation

Using npm: npm install poll-js

Using yarn: yarn add poll-js

Usage

import { pollWrapper } from 'poll-js';

const { future, cancel } = pollWrapper({
  request: fetch('github.com'),
  pollingPeriod: 1000 // ms,
  shouldStop: response => response.status === 200 
});

future
  .then(response => {...})
  .catch(error => {...})

// If by some reason you want to abort polling
cancel();  

API

.pollWrapper({request, pollingPeriod, shouldStop})

Returns Promise and cancel function. cancel allows manually terminate polling.

request - Function that returns Promise
pollingPeriod - Time in ms after request rejection and new attempt to perform it
shouldStop - Function which determines a condition for polling termination.

License

MIT © 2018 Mikhail Katrin mikhailkatrin@gmail.com

Keywords

js polling

FAQs

Package last updated on 10 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts