-
Notifications
You must be signed in to change notification settings - Fork 23
Execute actions based on conditions
Often it is required to execute some (conditional) statements when a condition is fullfilled:
IF a condition evaluates to true, we will DO some things.
Optionally other statements can be executed when the condition is not fullfilled:
IF a condition evaluates to true, we will DO some things. ELSE we will DO other things.
The following animation shows how we can have our actions depend on the payload of the input message (msg):
- When the payload contains 'true', we will log a warning 'true received'.
- When the payload contains another value (e.g. 'false'), we will log a warning 'false received'.
It is also possible to do some things when multiple conditions are fullfilled. The following animation shows how to execute statements if myVariable contains '_value _1' or 'value2':
You can add as much ELSE statements as you want. Moreover an ELSE IF can be added if another condition should be fullfilled before executing the statements in that ELSE part. However the result might become messy if the same input data is checked multiple times. For example:
In that case it might be better to use the switch block, where the input value needs to be specified only once. Depending on the different values, different actions will be taken: