'Calling' back a node?

I am developing some custom nodes for one of mine clients, and i got stuck on one part....

What i try to accomplish:
We have an 'IF' node with two outputs ,
first output executes first.
When flow from first output is finished , there is a 'End' node , witch task will be to save the output , and callback the 'if' node and pass some values to it.

image

I just used function nodes for displaying (everything will be a custom node-red node later),

Hi.

I think I understand what you mean, but a suggestion is rather than making this if node:
use a switch node and switch the message depending on a message property.

How is that "IF" and "END" node different to simply using built in nodes in series?

image

Let me set a bigger example here....
My output string at the end node should be
'if (output from previous node) { display.printLn }'
i want to pass it back to the if node , and the if node should just output it...

it is a clients wish on the work flow of the custom nodes i am building for him...

You may need to explain more on what is happening to the payloads in these nodes (the ones that change it) so it is better understood.

This is my best understanding of what you want to do:

[{"id":"4e2f011c.d78ae","type":"inject","z":"703c61ac.837e1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":560,"wires":[["e00c57d5.1901c"]]},{"id":"e00c57d5.1901c","type":"switch","z":"703c61ac.837e1","name":"\"IF\"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"str"},{"t":"eq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1430,"y":560,"wires":[["1db8d553.5b81db"],["8936c852.60eb5"]]},{"id":"1db8d553.5b81db","type":"function","z":"703c61ac.837e1","name":"Display","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1580,"y":540,"wires":[["91501c3b.87a88"]]},{"id":"91501c3b.87a88","type":"function","z":"703c61ac.837e1","name":"\"END\"","func":"//  The paylod MUST be modified here.\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1750,"y":490,"wires":[["e00c57d5.1901c"]]},{"id":"8936c852.60eb5","type":"function","z":"703c61ac.837e1","name":"Something else","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1600,"y":600,"wires":[[]]}]

Screenshot from 2021-01-02 22-12-35

Perhaps I am missing the point but I still dont see how that is different to wiring nodes in series.

I would convince your client that is somewhat anti-pattern. the wires in node-red symbolise flow of a msg.

Give your End node an output and connect it back to the If node input.

Edit, as I see @Trying_to_learn has suggested.

Independent of the question if this makes sense in Node red or not. A possible solution could be by creating a configuration node. The same configuration node has be selected in the configuration of the "if" and the "end" node. The "if" nodes must registere herself to the connected configuration node on creation. When the end node receives the message, it call a function in the configuration node which calls a function in all registered "if" nodes, which sends the messages given.

I'm not sure, but I think I've seen something like this before. Regardless of this, I would prefer the variant with the connection from the end to the if node, because you can see the connection between the nodes.

There is already this - do-red (node) - Node-RED

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.