Skip to content

Lazy Switch

Selects between two inputs based on a boolean switch, returning only the chosen value. This node is lazy: it only requires and evaluates the input for the active branch, allowing the inactive branch to remain unconnected without triggering computation.
Preview

Usage

Use this node to conditionally route one of two values (e.g., images, text, numbers, or other data) through your workflow based on a boolean flag. It is especially useful to avoid computing or loading heavy resources on the branch that will not be used.

Inputs

FieldRequiredTypeDescriptionExample
switchTrueBOOLEANControls which input is forwarded. If true, outputs on_true; if false, outputs on_false.true
on_falseTrueWILDCARDValue to output when switch is false. Can be any supported data type. Due to lazy behavior, this can be left unconnected if the switch will be true.An image value or a text string like "Option A"
on_trueTrueWILDCARDValue to output when switch is true. Can be any supported data type. Due to lazy behavior, this can be left unconnected if the switch will be false.An image value or a text string like "Option B"

Outputs

FieldTypeDescriptionExample
valueWILDCARDThe selected value based on the switch: on_true when switch is true, otherwise on_false.The chosen image or string based on the switch

Important Notes

  • Lazy evaluation: Only the selected branch is required. You may leave the unselected branch unconnected without errors.
  • Type consistency: The node does not convert types. Ensure downstream nodes can accept the type produced by the selected branch, and preferably keep both branches of compatible types.
  • Missing selected input: If the selected branch is not provided, the node may output null.
  • Boolean control: Non-boolean values are not accepted for the switch; provide a proper boolean input.

Troubleshooting

  • Output is null: Ensure the selected branch (based on switch) is connected and produces a value.
  • Downstream type mismatch: Confirm both branches supply the same or compatible types expected by downstream nodes.
  • Unexpected branch evaluation: Verify the switch boolean is set as intended and that any upstream logic correctly produces true/false.
  • Performance concerns: If heavy computation is triggered unexpectedly, check that only the intended branch is selected; the inactive branch should not execute due to lazy behavior.