An open API service indexing awesome lists of open source software.

https://github.com/imcuttle/interval-check

Polling check by intervally
https://github.com/imcuttle/interval-check

Last synced: about 1 year ago
JSON representation

Polling check by intervally

Awesome Lists containing this project

README

          

# interval-check

[![Build status](https://img.shields.io/travis/imcuttle/interval-check/master.svg?style=flat-square)](https://travis-ci.org/imcuttle/interval-check)
[![Test coverage](https://img.shields.io/codecov/c/github/imcuttle/interval-check.svg?style=flat-square)](https://codecov.io/github/imcuttle/interval-check?branch=master)
[![NPM version](https://img.shields.io/npm/v/interval-check.svg?style=flat-square)](https://www.npmjs.com/package/interval-check)
[![NPM Downloads](https://img.shields.io/npm/dm/interval-check.svg?style=flat-square&maxAge=43200)](https://www.npmjs.com/package/interval-check)
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://prettier.io/)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)

> Polling check by intervally

## Installation

```bash
npm install interval-check
# or use yarn
yarn add interval-check
```

## API

### setIntervalCheck

#### Parameters

- `fn` {Function}
- `shouldStop` {() => boolean | Promise}
- `interval` {number}

#### Examples

```javascript
import setIntervalCheck from 'interval-check'

let data
fetch('/data').then((res) => {
data = res
})

const dispose = setIntervalCheck(
() => {
console.log('fetching /data')
},
() => !!data,
1000
)
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**

## Contributing

- Fork it!
- Create your new branch:
`git checkout -b feature-new` or `git checkout -b fix-which-bug`
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
`git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`
- Push to the branch: `git push`
- Submit a pull request :)

## Authors

This library is written and maintained by imcuttle, moyuyc95@gmail.com.

## License

MIT - [imcuttle](https://github.com/imcuttle) 🐟