If
This node provides conditional logic by routing signals based on boolean input.
The If node evaluates a boolean condition and triggers different signals based on the result.
The If node implements conditional branching logic. It evaluates a boolean input when triggered and emits either a True Condition or False Condition signal based on the result. It is the fundamental node for creating decision-based workflows and logic forks.
Inputs
General
| Data | Description |
|---|---|
| Boolean Input | The condition to evaluate. Expects a true or false boolean value. |
Control
| Signal | Description |
|---|---|
| Do | Triggers the condition evaluation. The logic is only executed when this signal is received. |
Outputs
Signals
| Signal | Description |
|---|---|
| True Condition | Triggered if the Boolean Input is strictly true. |
| False Condition | Triggered if the Boolean Input is strictly false. |
Usage
Conditional Flow Control
The If node enables branching logic in your application:
- Set Condition: Connect a boolean value (e.g., from a comparison node or variable) to the
Boolean Input. - Trigger Evaluation: Send a signal to the
Doinput (e.g., from a button click or previous node). - Handle Results: Connect the
True Conditionoutput to the logic you want to run when true, andFalse Conditionto the logic for false.
Example Use Cases
- User Authentication: Route users based on login status.
Boolean Input:isLoggedInvariable.True Condition: Navigate to Dashboard.False Condition: Show Login Form.
- Form Validation: Handle valid vs invalid form data.
Boolean Input:isFormValid.True Condition: Submit Form.False Condition: Show Validation Errors.
- Feature Flags: Enable/disable features conditionally.
Boolean Input:featureEnabled.True Condition: Show New Feature.False Condition: Show Default UI.
- Toggle Logic: Switch between two states.
Detailed Behavior
- Strict Boolean Check: The node checks if the input is strictly
trueorfalse. - Null/Undefined Handling: If the
Boolean InputisnullorundefinedwhenDois triggered, neither output signal is fired. This is a safety feature to prevent unexpected behavior from uninitialized variables. - No Side Effects: The node does not modify any data; it only routes the flow of execution.
Troubleshooting
- No Output Signal: If you trigger
Doand neitherTrue ConditionnorFalse Conditionfires, yourBoolean Inputis likelynullorundefined. Ensure the input variable is properly initialized. - Unexpected Branch: Verify the source of your boolean input. Use a "Debug" or "Log" node to inspect the value being passed to
Boolean Inputbefore the If node.