Hi -
I was previously looking into Async and was fortunate enough to stumble upon your library and like what I'm seeing in the docs but can't seem to find this use case spelled out clearly.
I'm making use of
https://github.com/husanu/nodejs-cpu-usage, and running it every 10 seconds to get the latest value. Elsewhere in the same file, I run a loop every 30 seconds and just want to pull the latest value from cpu-usage. Currently, my code looks like
var readCpu = deferred.promisify(require("cpu-usage"));
var last_cpu = 0;
readCpu(10000, function(load) {
last_cpu = load;
});
var HEARTBEAT_INTERVAL = 30*1000;
temporal.loop( HEARTBEAT_INTERVAL, function() {
...
results.cpu = last_cpu;
...
}
when really I would just like to do something like
readCpu(10000);
var HEARTBEAT_INTERVAL = 30*1000;
temporal.loop( HEARTBEAT_INTERVAL, function() {
...
results.cpu = readCpu.value(); // reflects last value returned
...
}
So, I'm not sure if I'm using the deferred semantics as intended, or if I'm missing something already supported, or if I'm introducing something new to the mix. I'd be grateful for some help.
Thanks very much,
Steve