subflow
#38
Replies: 1 comment 1 reply
-
At least the id of the subflow "node" needs to be kept in the output - to be able to assign error & status messages to it's visual representation in the editor. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been looking into implementing subflows in Node-RED MCU Edition. It is not a small project. Subflows bundle together a set of nodes for reuse within a project and publishing to npm to share. Subflows are perhaps the largest unimplemented structucal feature in Node-RED MCU Edition. It looks possible to support them, but there are many details to consider. I'm opening this discussion thread to share my current thoughts and notes.
A subflow is node that contains a collection of nodes. A subflow has these characteristics:
NR_FLOW_ID
andNR_NODE_PATH
.An instance of a subflow behaves like an ordinary node. In the Node-RED Editor, a subflow looks like an ordinary node. But the implementation is a set of Node-RED nodes rather than JavaScript code.
Each instance of a subflow creates a clone of the subflow and the nodes it contains. The cloned subflow and nodes all received unique
ID
values. This requires updating all connections within the subflow (wire
,scope
,link
, etc) the newID
values. The step of assigning newID
values for each instance ensures that each node in the Node-RED runtime has a unique ID, even when a subflow is instanced more than once.Most of the work to support subflows can be done at build time in the
nodered2mcu
tool. Each instance of a subflow creates a new flow instance. The subflow template, including all its child nodes, should not appear in the output.In theory, a subflow with no environment variables could be instanced with only nodes (though this would change the value of
NR_NODE_PATH
). This optimization doesn't seem worth pursuing because it looks complicated and environment variables seem essential to configuring subflows.The Node-RED Editor renders the the inputs and outputs of a subflow as special nodes. However, they are not nodes, but just wires. The
nodered2mcu
tool needs to connect the inputs and outputs of each subflow instance node to the corresponding nodes in their containing flow.Beta Was this translation helpful? Give feedback.
All reactions