best-poller
v0.1.1
Published
A basic poller built on top of promises, based on the typescript.
Downloads
5
Maintainers
Readme
Best Poller
Create Poller
let getInfo = function(key) {
return new Promise((resolve, reject) => {
setTimeout(() => {
let random = Math.random()
if (random > 0.5) {
resolve({
type: 'success',
key,
random
})
return
}
reject({
type: 'error',
key,
random
})
}, 300)
})
}
// create poller
let poller = new BestPoller(getInfo, {
key: 1
}, 1000, (re) => {
// success
}, (error) => {
// error
})
destroy
poller.destroy()
stop
poller.stop()
continue
poller.continue()