2021年4月10日星期六

Node-Red debug node not showing unique payload for custom node

I was playing with a custom node plugin that sends multiple output, and it is not showing unique msg.payload in debug window as compared to running the same logic via a function node.

Snapshot of the simple flow using a regular function node (debug shows five unique payloads): Simple flow using a function node

Snapshot of the same flow using a custom node wrapping the same code, but shows only the last payload repeated five times: Same flow with a simple custom node

Simple custom node code:

module.exports = function(RED) {      function SimpleNode(config) {          RED.nodes.createNode(this, config);          var node = this;            node.on('input', function(msg, send, done) {              var name = msg.payload.name;              var count = msg.payload.count;                for (var i = 0; i < count; i++) {                  msg.payload = "Hello, " + name + i;                  console.log("msg", msg);                  send(msg);              }          });      }        RED.nodes.registerType("simple", SimpleNode);  };  
https://stackoverflow.com/questions/67040581/node-red-debug-node-not-showing-unique-payload-for-custom-node April 11, 2021 at 09:03AM

没有评论:

发表评论