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 by evaluating a boolean input when triggered and emitting either a true or false signal based on the result. It's fundamental for creating decision-based workflows.
Inputs
General
| Data | Description |
|---|---|
| Boolean Input | The condition to evaluate |
Control
| Signal | Description |
|---|---|
| Do | Triggers the condition evaluation |
Outputs
Signals
| Signal | Description |
|---|---|
| True Condition | Triggered when boolean input is true |
| False Condition | Triggered when boolean input is false |
Usage
Conditional Flow Control
The If node enables branching logic in your application:
- Set Condition: Connect a boolean value to the Boolean Input
- Trigger Evaluation: Send a signal to the Do input
- Handle Results: Connect appropriate logic to True/False outputs
Example Use Cases
-
User Authentication: Route users based on login status
Boolean Input: isLoggedIn
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 -
Data Processing: Route data based on conditions
Boolean Input: hasData
True Condition: Process Data
False Condition: Show Empty State
Best Practices
- Clear Conditions: Use meaningful boolean expressions
- Handle Both Cases: Always connect both true and false outputs
- Avoid Side Effects: Keep condition evaluation pure
- Error Handling: Consider undefined/null boolean values