mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
add reset feature to batch node
This commit is contained in:
@@ -179,6 +179,11 @@ module.exports = function(RED) {
|
||||
}
|
||||
node.pending = [];
|
||||
this.on("input", function(msg) {
|
||||
if (msg.hasOwnProperty("reset")) {
|
||||
node.pending = [];
|
||||
node.pending_count = 0;
|
||||
return;
|
||||
}
|
||||
var queue = node.pending;
|
||||
queue.push(msg);
|
||||
node.pending_count++;
|
||||
@@ -204,11 +209,19 @@ module.exports = function(RED) {
|
||||
var interval = Number(n.interval || "0") *1000;
|
||||
var allow_empty_seq = n.allowEmptySequence;
|
||||
node.pending = []
|
||||
var timer = setInterval(function() {
|
||||
function msgHandler() {
|
||||
send_interval(node, allow_empty_seq);
|
||||
node.pending_count = 0;
|
||||
}, interval);
|
||||
}
|
||||
var timer = setInterval(msgHandler, interval);
|
||||
this.on("input", function(msg) {
|
||||
if (msg.hasOwnProperty("reset")) {
|
||||
clearInterval(timer);
|
||||
node.pending = [];
|
||||
node.pending_count = 0;
|
||||
timer = setInterval(msgHandler, interval);
|
||||
return;
|
||||
}
|
||||
node.pending.push(msg);
|
||||
node.pending_count++;
|
||||
var max_msgs = max_kept_msgs_count(node);
|
||||
@@ -230,6 +243,11 @@ module.exports = function(RED) {
|
||||
});
|
||||
node.pending = {};
|
||||
this.on("input", function(msg) {
|
||||
if (msg.hasOwnProperty("reset")) {
|
||||
node.pending = {};
|
||||
node.pending_count = 0;
|
||||
return;
|
||||
}
|
||||
concat_msg(node, msg);
|
||||
});
|
||||
this.on("close", function() {
|
||||
|
Reference in New Issue
Block a user