@oada/poll
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

OADA/poll

An oada library for regularly executing a callback, ideally for polling a remote. Users control the interval between execution. The last check time is stored at <basePath>/_meta/oada-poll/<name>.

Basic Usage Example

import { poll } from '@oada/poll'

// See type definitions for all supported options
await poll.poll({
  connection, //an @oada/client connection (oada.connect result)
  basePath: `/bookmarks/services/foo`,
  pollOnStartup: true, //execute immediately on startup (true) or wait interval (false)
  pollFunc: async() => {  },
  interval: 3600*1000 //interval time in milliseconds
  name: 'my-poll-service',
});

Optional Arguments

By default, the service checks whether it is time to poll with a frequency of interval/2. This can be controlled by the argument checkInterval, e.g.:

await poll.poll({
  ...
  checkInterval: 1000 // check interval time in milliseconds
});

Readme

Keywords

none

Package Sidebar

Install

npm i @oada/poll

Weekly Downloads

8

Version

1.0.4

License

Apache-2.0

Unpacked Size

32.3 kB

Total Files

8

Last publish

Collaborators

  • sanoel
  • serviopalacios
  • aultac
  • awlayton
  • oadao
  • tarakawa
  • cyrusbowman
  • abalmos