Switch
Routes execution to one of several case ports.
@lainstack/flow/switch · Flow
How to use it
Section titled “How to use it”Use this block to pick one path from up to 8 exact values. It compares the subject with each case value for equality and leaves on case_1 to case_8, or on default when no case matches. For ranges, ordering, contains tests or a plain yes or no, use @lainstack/flow/condition.
- The cases are checked in order and the first match wins. The output is empty.
- Case values must differ from each other, and each case must use its own port. Two equal values make the config invalid.
- Every case value is resolved on each run, even after an earlier case matched. A case value that has no value, for example a reference to a block that did not run, fails the step with
comparison_invalid. The subject fails the same way. - Text matching ignores letter case unless
settings.matchCaseis true.settings.timezoneapplies only to date and time values. Other value types take no settings. - Wire
defaultif an unexpected value must not go unhandled.
Settings
Section titled “Settings”| Setting | Key | Type | Details |
|---|---|---|---|
| Subject (required) | subject |
Text | |
| Cases (required) | routes |
List | At most 8 items. |
| Exit | Port | Notes |
|---|---|---|
| Case 1 | case_1 |
|
| Case 2 | case_2 |
|
| Case 3 | case_3 |
|
| Case 4 | case_4 |
|
| Case 5 | case_5 |
|
| Case 6 | case_6 |
|
| Case 7 | case_7 |
|
| Case 8 | case_8 |
|
| Otherwise | default |