toloka.client.project.template_builder.helpers.SwitchHelperV1
| Source code
SwitchHelperV1( self, cases: Optional[Union[BaseComponent, List[Union[BaseComponent, Case]]]] = None, default: Optional[Any] = None, *, version: Optional[str] = '1.0.0')
A switch-case construction.
Checks various conditions sequentially and executes the code from the result property when the corresponding condition is true.
You can use it to perform an action or display an additional interface element only when a certain condition is met. View example in the sandbox.
This helper is similar to a series of If...Then...Else logical expressions, so it is useful if there are more than two conditions for sequential verification. If you need to check one or two conditions, use the helper.if component. How the helper works:
Parameters | Type | Description |
---|---|---|
cases | Optional[Union[BaseComponent, List[Union[BaseComponent, Case]]]] | An array of objects consisting of condition and result property pairs. |
default | Optional[Any] | Element that is returned if none of the checked conditions returned true. |