A Timer used to Detect and Recover from Malfunctions.
Picture Credit: Using Watchdog Timer
$ npm install watchdog
...
import { Watchdog } from 'watchdog'
const TIMEOUT = 1 * 1000 // 1 second
const dog = new watchdog(TIMEOUT)
const food = { data: 'delicious' }
dog.on('reset', () => console.log('reset-ed'))
dog.on('feed', () => console.log('feed-ed'))
dog.feed(food)
// Output: feed-ed
setTimeout(function() {
dog.sleep()
console.log('dog sleep-ed. Demo over.')
}, TIMEOUT + 1)
// Output: reset-ed.
// Output: dog sleep-ed. Demo over.
In developing ...
- Support browser (#31)
- Init watchdog
Thanks to Damon Oehlman (https://github.com/DamonOehlman)
who owned the watchdog
name of NPM module.
He is so kind and nice that passed this name over to me after my request.
- Code & Docs © 2017-now Huan LI <zixia@zixia.net>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons