Switch block
Purpose
To control the state of components or blocks, that takes a true/false value. Often used to set the visibility of components. All inputs execute when a truthy value is received.
Input
-
Flip
Flips the state from what it was to the opposite (on/off). Remember to indicate the initial state with the checkbox, unchecked means the initial state is off, while checked means the initial state is on. If not set correctly, the first click will not work. -
Turn on
Turns output off. The initial state checkbox has no effect. -
Turn on
Turns output on. The initial state checkbox has no effect.
Output
- On / Off
Outputs a boolean (true / false).
Example
When the user clicks my button, the container (including everything it includes) should hide.
graph LR A(click) --Turn off--> B(Switch) B --On / Off--> C(Container Visibility)
Caveats
- If multiple sources control the same component, the 'flip' cannot keep track of state. Therefore it will only work sometimes.
- Sending no text (e.g. "") will be interpreted as false. Be aware of that when using the block with text fields.