Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 581 Bytes

README.md

File metadata and controls

54 lines (43 loc) · 581 Bytes

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)
	})
}

let polling = new Polling(iotGetWifiDeviceStatus, {
	key: 1
}, 1000, (re) => {
	// success
}, (error) => {
	// error
})

destroy

	polling.destroy()

stop

	polling.stop()

continue

	polling.continue()