SwitchAction

FlowActions. SwitchAction

An action 'switch' that can test several branches, and execute an array of actions if the branch matches

Each branch is tested in the order they are present in the array.

The where option is used as a filter, and if the filter matches the actions in then is applied

Default is to break after a branch matches, but if "break": false is added as an option, it will continue to next branch

If a branch has no where option, it is always executed if no branch has breaked until it is reached.

Constructor

new SwitchAction()

Source:
Example
{
    "switch": [
        {
            "where": {"property": "myProperty", "equals": "myValue"},
            "then": ["myAction", "myOtherAction"],
            "break": true
        },
        {
            "where": {"property": "myProperty", "equals": "myOtherValue"},
            "then": ["myAction", "myOtherAction"],
            "break": true
        },
        {
            "then": ["myDefaultAction"]
        }
    ]
}