While Loop Node in Pathways: Difference between revisions
(While Loop Node) |
m (Mitchell.Hirsche moved page Documentation for the While Loop Node in Pathways to While Loop Node in Pathways) |
Latest revision as of 23:08, 5 March 2025
The While Loop node in Pathways is used to repeatedly execute a sequence of tasks while a specified condition remains true. This is particularly useful for iterative processes or workflows that require continuous execution until a logical condition is no longer satisfied.
Configuration Options
- Name
- Description: A descriptive label for the While Loop node to easily identify its purpose in the workflow.
- Input: Text field.
- Example: "Validate Data Input Loop".
- Condition
- Description: The logical condition that determines whether the loop continues to execute. The loop will run as long as this condition evaluates to true.
- Input Type: Dropdown with two options for defining the condition:
- Script: Allows the user to define a condition using custom script logic for complex evaluations.
- Handlebars Template: Enables the use of Handlebars expressions for simple, template-driven logic.
- Required: Yes.
- Example:
- Script: data.value < 100
- Handlebars Template: {{data.isValid}}.
How It Works
- The node evaluates the Condition before every iteration.
- If the condition is true:
- Executes the sequence of tasks defined in the loop.
- Rechecks the condition after execution.
- If the condition is false:
- The loop stops, and the workflow continues to the next step.
Practical Example
Suppose you want to monitor a data stream until a specific value exceeds a threshold:
- Configure the Condition as data.temperature < 75.
- Inside the loop, define tasks such as logging the current temperature and sending alerts if required.
- Once the temperature reaches 75 or higher, the loop stops, and the workflow proceeds.
Notes
- Ensure the condition is well-defined to avoid infinite loops.
- Use appropriate error handling or exit strategies if the condition might result in extended iterations.
- Combine with nodes like Break to programmatically exit the loop under specific scenarios.
This node is a flexible tool to add iterative functionality to your Pathways workflow, enabling dynamic and responsive execution paths.