Skip to content

Design: subflows vNext

Nick O'Leary edited this page Jul 23, 2015 · 18 revisions

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.

Definitions

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.

inline-subflow

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 move the definition to the top level, and the flow node replaced with a subflow-instance node.

template-subflow

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.

loop-subflow

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.

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)

Clone this wiki locally