Created
August 13, 2014 07:53
-
-
Save yorkie/3ff4bd971db5857ce6da to your computer and use it in GitHub Desktop.
idle-hands is not really idle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var idlehands = require('idle-hands'); | |
var timerCount = 0; | |
var idleCount = 0; | |
function repeat(cb) { | |
setImmediate(function() { | |
timerCount += 1; | |
}); | |
idlehands.once('idle', function() { | |
idleCount += 1; | |
console.log(timerCount, idleCount); | |
cb(cb); | |
}); | |
} | |
idlehands.once('idle', function(){ | |
repeat(repeat); | |
}); | |
idlehands.start(); | |
setInterval(function(){ | |
request('http://google.com'); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output:
Such that the event
idle
will be called in every tick, it just run3:run_idle
function like this digram: http://readtrend.com/icon/5311