1.0.3 • Published 9 years ago

gallup v1.0.3

Weekly downloads
51
License
BSD-3-Clause
Repository
github
Last release
9 years ago

TravisCI shield npm shield js-standard-style

Poll any resource using ES6 Promises and streams.

Installation

$ npm install gallup --save

Usage

import Gallup from 'gallup'

// You construct a poller by providing a poll callback as the first argument
// and an optional options object as the second. The poll function may return a
// normal value or an ES6 Promise to be evaluated.

var poller = new Gallup(() => {
    return Promise.resolve({ stub: 'data' })
}, 5000) // poll every 5 seconds (default: 1 second)

// Pollers are stopped by default. Starting them begins polling immediately.
poller.start()

// Pollers are instances of EventEmitter. When promises resolve, their values
// are emitted via 'data' events. Errors are emitted via 'error' events. If the
// previous poll is taking a long time to resolve, another poll will not be
// initiated until the previous one completes.

poller.on('data', data => {
  console.log(data)
})

poller.on('error', err => {
  console.error(err)
})

// You can also stop and restart polling.
poller.stop()
poller.start()

Development

Gallup uses JavaScript Standard Style, Babel for ES6+ support, and Jest for testing.

$ git clone git@github.com:pavlovml/gallup.git
$ npm test

To run the tests on file changes:

$ npm test -- --watch

License

BSD 3-Clause

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago