Create a new node with multiple inputs directly?

I just want to create a new node with multiple inputs. This node will:
show multiple inputs' ports;
generate {node_id: output_name} in its json,when linked with other node's output.

Node-RED doesn't support multiple input ports

4 Likes

I mean rewriting codes to support it.

1 Like

Just to clarify... you want to rewrite the entire node-red runtime and editor to support multiple inputs? Something we've said repeatedly (if you search the forum) is not supported?

You'll forgive me if, at a time we're focussed on getting 1.0 released, that I don't spend a day writing out everything that would need to be changed to do that.

3 Likes

Supporting only one input was a fundamental design choice (and a good one, IMO), otherwise the flow engine would have to be a lot more complex.

There was a nice discussion about this topic a while ago here:

2 Likes

The function example with 2 inputs to do a Division is not a good example as to why multiple-inputs would be beneficial (each input receives messages potentially at different time while the function would need access to both parameters simultaneously - a JOIN node does the trick for that).

However, here's a good (IMHO) reason to consider implementing multiple node inputs in the future (I understand that it's not a simple, localized change, so I imagine it would be a distant future, but I can help with this task):

  1. Collapse a Group into a single box/node/subflow - currently a group may have multiple links on either side (ins and outs) as there could be multiple wires leading to it. Once converted to a subflow, it would require each message to be identifiable by topic or otherwise (to avoid collision when directing all inputs to a single port) and a split node inside the subflow to extract each input ...
  2. Building a complex flow is quite messy right now as not everything can be done with subflows (although, I hope that single-instance subflows / nodes will be eventually implemented) - for example, I can't link to a subflow element, all inputs have to go through a single port - quite a mess to figure it all out. Object-oriented-like flows would allow for complex nodes to be defined on separate tabs (as 'subflows' or 'classes') and shown on the main flow as a single box with multiple inputs/outputs, possibly with a multi-line label that I'd also like to see). This nesting could be hierarchical, building a complex machinery from smaller and smaller blocks.
  3. Multiple inputs could be implement as simply as supplying an array of messages on the current single port - similar to how send([...]) allows to address multiple outputs. Perhaps that would be enough to do the trick + visual layout of course?
3 Likes