Widgets/Producer

Loop

Loop

A "Producer" type widget. Loop Widget iterates over an array of items. For each item in the array, it transmits the item itself through the output port and its zero-based index through the index port. Once all items have been processed, it transmits a true boolean value through the finish port.

The Loop Widget supports both manual iteration (requiring triggers on the next port) and automatic iteration (when Auto-Loop is enabled). It can also automatically clear its internal state after completion for memory management.

 

Inputs

  • array (DataType: Array) Receives an array to be iterated over. When an array is received, the Loop Widget will store it internally and reset the current index to 0. If Auto-Loop is enabled, the Loop Widget will immediately start iterating through all items.

  • next (DataType: Anything) Triggers the processing of the next item in the array. If Auto-Loop is disabled, this port must be triggered for each item in the array to process them one by one.

  • clear (DataType: Anything) Clears the last received array and resets the widget's state. This is useful for freeing up memory or preparing the widget for a new array.

Outputs

  • output (DataType: Automatically determined) Transmits the current item from the array. The data type of this port will match the type of the items in the input array (Number, String, Object, etc.).

  • index (DataType: Number) Transmits the zero-based index of the current item being processed.

  • finish (DataType: Boolean) Transmits true when the loop has finished iterating over all the items in the array.


Custom Settings

This widget offers settings to customize its behaviour.

  • Auto Loop When enabled, the widget will automatically iterate through all the items in the array as soon as it's received on the array port. If disabled, you will need to trigger the next port to process each item.

  • Auto Clear If enabled, the widget will automatically clear the internal array after the loop has finished. This is useful to free up memory when the array is no longer needed.


Loop Configuration

 

Examples

Manual Iteration (Auto Loop Disabled)

This example shows how to manually control the iteration process by triggering the next port for each item:


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Button widget triggers the Text widget to start the process
  2. The Text widget contains the array ["apple", "banana", "orange"] and transmits it to the Text to Object widget
  3. The Text to Object widget parses the JSON string and transmits the array to the Loop widget through the array port
  4. Auto Loop is disabled, so the Loop widget stores the array but doesn't start processing
  5. Each time the next port on the Loop widget is triggered:
    • Transmits the current item through the output port to the Text widget
    • Transmits the current index through the index port to the Display widget
    • The internal index is incremented
  6. After processing the last item, the finish port transmits true to the Display widget
  7. The Loop widget is ready to process the same array again if next is triggered

 

Automatic Iteration (Auto Loop Enabled)

This example demonstrates automatic iteration through all items in the array:


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Button widget triggers the process
  2. The Text widget contains the array [1, 2, 3, 4, 5] and transmits it to the Text to Object widget
  3. The Text to Object widget parses the JSON string and transmits the array to the Loop widget through the array port
  4. Since Auto Loop is enabled, the Loop widget immediately starts processing all items
  5. The Loop widget automatically:
    • Transmits each number through the output port to the "Delay 1 sec" custom widget
    • Processes all items sequentially without manual intervention
  6. The "Delay 1 sec" custom widget introduces a 1-second delay before passing each value to the Display widgets
  7. The Display widgets show the processed values
  8. After processing the last item (5), the Loop widget transmits true through the finish port to the Display widget
  9. The Loop widget is ready to process a new array if one is provided

 

📌 Notes

  • The Loop Widget automatically detects the output data type from the first item in the array
  • Index is 0-based (first item is at index 0)
  • When Auto Loop is disabled, you must trigger the next port for each item you want to process
  • When Auto Loop is enabled, all items are processed synchronously without delays. For step-by-step visualization, use custom widgets with timing delays or manual iteration triggers.
  • The finish port transmits true only after the last item has been processed
  • Auto Clear is useful for memory management in long-running recipes
  • The clear port preserves user settings (autoLoop and autoClear) while resetting the internal state
  • Works with any array type (numbers, strings, objects, mixed types)
  • The Loop Widget maintains separate state for each widget instance

 

Glossary

  • Array

    A collection of elements (numbers, strings, objects, etc.) stored in order, accessible by position.

  • Index

    A position number starting from 0 that identifies an item's location in an array.

  • Iteration

    The process of repeating operations for each item in a collection.

  • Memory Management

    Efficiently managing computer memory to prevent waste and optimize performance.

  • Custom Widget (Widget Group)

    A user-created widget built by grouping other widgets together, with custom inputs, outputs, and settings. Custom widgets allow users to create reusable components for complex workflows. In the examples above, the "Delay 1 sec" custom widget introduces timing delays between loop iterations to demonstrate the widget's behavior more clearly. (For more information, click the "?" icon on the custom widget in the workspace.)