commit 2cbfe63ed229d1a4ec89b6964ec7b16e72dc052d
parent 195d1d06c5cd963a9523fd701ab216c5dafc0db2
Author: MTRNord <mtrnord1@gmail.com>
Date: Sat, 10 Sep 2016 20:51:15 +0200
optimize endless loop
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/main.js b/main.js
@@ -93,7 +93,7 @@ function GetData(){
}
}).setMaxListeners(0);
//Rerun Function after 10 seconds
- setTimeout(function() { GetData(); }, 10000);
+ setTimeout(function() {}, 10000);
}
//Handle "[CTRL]+[C]"
if (process.platform === "win32") {
@@ -161,8 +161,16 @@ async.auto({
telegram.start(callback)
},
GetData: function (callback) {
- //Run Mainfunction 20seconds after script start
- setTimeout(function() { GetData(callback); }, 20000)
+ async.forever(
+ function(next) {
+ GetData(next)
+ callback(err)
+ },
+ function(err) {
+ // if next is called with a value in its first parameter, it will appear
+ // in here as 'err', and execution will stop.
+ }
+ );
}
},
function(err, result) {