-
Notifications
You must be signed in to change notification settings - Fork 0
Design: subflows vNext
The existing subflow capability in node-red serves a purpose, but is need of further development to be truly useful.
The follow design outlines where we'll go next with subflows.
There are three types of subflow:
-
inline-subflow: a subflow that is defined and used once within a single flow. It is not reusable. Inputs: 0/1, Outputs: 0/n -
loop-subflow: a subflow that defines a condition under which a message is iterated on. Inputs: 1, Outputs: 1 -
template-subflow: a subflow that is added to the palette as a reusable set of nodes. This is equivalent to what we have today. Inputs: 0/1, Outputs: 0/n. It defines a set of properties of its nodes that can be customised by individual instances.

A new subflow node is available in the function section of the palette. This can be dragged onto the workspace to create an inline-subflow. It defaults to 1-input/1-output as we expect subflows to most commonly be used mid-flow.

An option exists in the subflow toolbar to add it to the palette. This will extract the subflow definition, and substitute a subflow-instance node in its place.

When editing a template-subflow, the edit properties button presents a list of all nodes in the subflow and their configurable properties. This will be limited to properties the editor is able to identify as being string/boolean/number/config node types - Object/Array types won’t be available. The user can then select which properties should be exposed to subflow instances.
The edit dialog for an individual subflow-instance will then present a corresponding list of selected properties and allow the user to provide instance-specific values.
The remove from palette button does just that. If there is one instance of the subflow, it is automatically converted to an inline-subflow. If there are more than one, a dialog is shown to ask the user whether to convert each to an inline-subflow, or to delete all instances.

A new loop node is available in the function section of the palette. This can be dragged on to the workspace to create a loop-subflow. (node colour/icon tbd)
It is fixed to 1-input and 1-output - this cannot be changed.

The loop condition is configurable in the toolbar (quick ui mock-up - need to test if there’s enough room to do it in the toolbar directly, or via some other means)
aka - how one thing can become another, and back again.

Notes:
-
The existing subflow menu options will change.
-
Create subflowwill be removed - dragging a subflow node will be the primary way of creating a blank subflow. -
Selection to subflowwill becomegroup nodes- and will create an inline-subflow -
ungroup nodeswill be added - and will remove a inline-subflow and reinsert its content in the flow. - need to test the terms 'group' and 'ungroup'
-
-
Whilst it is possible to convert inline-subflow to template-subflow and back, it is not possible to convert to/from a loop subflow.