IfNode and SwitchNode.
Overview
Conditional workflows enable:- Branch execution based on runtime conditions
- Skip nodes when conditions aren’t met
- Dynamic path selection based on values
- Multi-way routing with switch/case logic
Basic If/Else Flow
TheIfNode provides classic if/else conditional branching:
How It Works
BooleanInputNodeprovides the condition value (true/false)IfNodereceives the condition and optional data- Based on condition:
true→ Routes tothenOutputfalse→ Routes toelseOutput
- Only the active branch executes - the other is skipped
Numeric Comparison
Use comparison nodes to generate boolean conditions:Available Comparison Operators
>- Greater than>=- Greater than or equal<- Less than<=- Less than or equal==- Equal!=- Not equal
Switch/Case Routing
TheSwitchNode provides multi-way branching:
Dynamic Outputs
SwitchNode generates outputs dynamically based on the cases property:
- 3 cases → 4 outputs:
case_0,case_1,case_2,default - Add case → new output appears automatically
- Remove case → output disappears
Nested Conditionals
Conditional nodes can be nested for complex decision trees:If Inside If
Switch Inside If
Advanced Patterns
Multi-Stage Validation
Validate data through multiple conditional checks:State Machine
Implement state transitions with switch:React Component Example
Try It Yourself
The CrystalFlow examples package includes a completeConditionalNodesDemo.tsx with:
- All logic test nodes (CompareNode, IsPositiveNode, IsEvenNode, etc.)
- IfNode and SwitchNode from @crystalflow/core
- 7 documented workflow scenarios
- Full interactive UI with property panel for configuring cases
Key Concepts
Branch Evaluation
evaluateCondition() determines which branch executes at runtimeSingle Branch Execution
Only the active branch runs - others are completely skipped
Dynamic Outputs
SwitchNode outputs update automatically when cases change
Nested Conditionals
Conditionals can be nested arbitrarily deep for complex logic
Next Steps
Conditional Flow Guide
Deep dive into conditional flow architecture
Built-in Nodes API
Complete IfNode and SwitchNode API reference
Creating Custom Nodes
Build your own conditional nodes
Data Processing
More workflow examples