Hi,
Sorry if a repost (please point me in case this was already discusses)
I am developing a custom node which needs to do multiple sends from within its input handler. I see a difference between custom & function nodes:
In a function node, if I use node.send(msg) multiple times, it will send separate msg instances. For example:
msg.payload = "AAA"
node.send(msg)
msg.payload = "BBB"
node.send(msg)
=> will send the payloads AAA, BBB as intended.
However in a custom node, the runtime seems to send twice the same msg instance (in its latest state). For example:
node.on('input', function(msg, send, done) {
msg.payload = "AAA"
send(msg)
msg.payload = "BBB"
send(msg)
done()
});
=> will send BBB, BBB.
Is this is because the runtime defers the actual sending, hence 1st msg is impacted by the modification for the 2nd send?
I can work around this by creating new msg instances (let msg2 = {payload:"BBB"} etc.), but just wanted to know if I should be doing something else.
Thanks!