@oada/poll
v1.0.4
Published
A library for controlling a regularly-polling service.
Downloads
25
Keywords
Readme
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
});