switch
A switch expression. If none of the defined cases match _default
case is executed.
Field Configurations
Key | Type | Description | Default Value |
---|---|---|---|
"params" (required) | Object | undefined | null |
Parameters
Key | Type | Description | Default Value |
---|---|---|---|
"async" | Boolean | Specifies whether the action should perform asynchronously. | null |
"cases" (required) | Object | Possible cases. Use _default to create default case. | null |
"value" (required) | Object | Expression that should be evaluated. | null |
Inherited
From Base Action
Base Action
Field Configurations
Key | Type | Description | Default Value |
---|---|---|---|
"dynamicParams" | Object | Dynamic params to retrieve data from a specific context e.g. a userSetting. | null |
"leadingDelimiter" | String | The leading mustache delimiter to use. | null |
"params" | Object,Array | Object containing the properties of the action. | null |
"trailingDelimiter" | String | The trailing mustache delimiter to use. | null |
"type" | String | Type name of the action. | null |
Examples
Example: switch expression
Goal: Create switch expression to decide what to do.
Evaluate exampleValue
to decide which message should be displayed.
{
"type": "switch",
"params": {
"value": {
"context": "device",
"field": "os"
},
"cases": {
"android": [
{
"type": "showMessage",
"params": {
"text": "You are using Android"
}
}
],
"iOS": [
{
"type": "showMessage",
"params": {
"text": "You are using iOS"
}
}
],
"_default": [
{
"type": "showMessage",
"params": {
"text": "You are neither using Android nor iOS"
}
}
]
}
}
}
The actions to be executed are specified in the actions
parameter, in this case a switch action.
Result:
A switch action has been created