1.0.2 • Published 7 years ago

watchdog-callback v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

watchdog-callback

npm install watchdog-callback --save

I use it for socket.io. In the example below the callback may never be called:

    function callback(err, data) {
        if (err) {
            return console.error(err);
        }
        // have fun with data
    }
    socket.emit('any-event', callback);

To make sure it will, use the watchdog:

    var wdc = require('watchdog-callback');
    function callback(tout, err, data) {
        if (tout) {
            return console.error(tout);
        }
        if (err) {
            return console.error(err);
        }
        // have fun with data
    }
    socket.emit('any-event', wdc(callback));

The default timeout is 5000 milliseconds. You can change it:

    socket.emit('any-event', wdc(1000, callback)); // 1 second timeout
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago