1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

add checks for interval value

This commit is contained in:
Hiroyasu Nishiyama 2020-05-06 11:21:58 +09:00
parent 8750c4b121
commit ee13cd10fe

View File

@ -213,13 +213,20 @@ module.exports = function(RED) {
send_interval(node, allow_empty_seq); send_interval(node, allow_empty_seq);
node.pending_count = 0; node.pending_count = 0;
} }
var timer = setInterval(msgHandler, interval); var timer = undefined;
if (interval > 0) {
timer = setInterval(msgHandler, interval);
}
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg.hasOwnProperty("reset")) { if (msg.hasOwnProperty("reset")) {
if (timer !== undefined) {
clearInterval(timer); clearInterval(timer);
}
node.pending = []; node.pending = [];
node.pending_count = 0; node.pending_count = 0;
if (interval > 0) {
timer = setInterval(msgHandler, interval); timer = setInterval(msgHandler, interval);
}
return; return;
} }
node.pending.push(msg); node.pending.push(msg);
@ -232,7 +239,9 @@ module.exports = function(RED) {
} }
}); });
this.on("close", function() { this.on("close", function() {
if (timer !== undefined) {
clearInterval(timer); clearInterval(timer);
}
node.pending = []; node.pending = [];
node.pending_count = 0; node.pending_count = 0;
}); });