Flow Control
The logic flow is the order in which your nodes are executed. Usually, the flow start on a triggered event (manual play node, on load node, function...). Then, it follows the execution thread represented by a bold white link.
Flow control allows you to define the execution order of nodes in your graph and manage conditions or repetitions of actions.
Flow control is divided into three main categories:
- Triggers: Start the execution flow.
- Conditional Nodes: Change the execution flow based on a condition.
- Loops: Repeat actions based on a given criterion.
Triggers
Trigger nodes start the execution of logic when a specific event occurs.
Example: Log a message on click
- Add an On Click node connected to a button in your interface.
- Connect it to a Log node.
When the user clicks the button, the On Click node triggers the execution of the logic, and the Log node displays a message in the console.
Other triggers include On Mounted, On Load, and the input node of functions, routes, and crons. See Node Libraries.
Conditional Nodes (If)
Conditional nodes allow you to test a condition and execute different actions based on the result. A conditional node has:
- An execution input ()
- A condition input ()
- A true output ()
- A false output ()
Switch Node
The Switch node routes execution based on the value of an input, like a switch in JavaScript. For each declared case, a dedicated execution output is exposed; a default output catches unmatched values.
A Switch node has:
- An execution input ()
- A value input ()
- One execution output per declared case ()
- A
defaultoutput ()
Loop Nodes (For, For Each, While)
Loop nodes allow you to repeat an action multiple times based on a condition or a list.
Loops have an async mode: when enabled, each iteration waits for the previous one to finish before starting.
For Loop
The For node runs its loop output once for each index from 0 to count - 1, then runs its end output.
For Each Loop
The For Each node runs its loop output for each element of an array. A For Each node has:
- An execution input ()
- An array input ()
- An execution output ()
- An element output (of the array element type)
- An index output ()
- An end output ()
While Loop
A While loop node has:
- An execution input ()
- A condition input ()
- An execution output ()
- An end output ()
Sequence and Parallel
- Then runs its outputs one after the other:
Out 0, thenOut 1, thenOut 2... Use it to split a long flow into readable steps. - Parallel runs all its outputs at the same time and waits for all of them to finish before running
Done. Use it to run several API calls or queries at once.
Timing
| Node | Description |
|---|---|
| Sleep | Waits time milliseconds, then continues. The flow is paused. |
| Timeout | Runs its output after time milliseconds, without pausing the flow. |
| Debounce | Delays execution by time milliseconds. Each new trigger resets the timer, so only the latest one continues. Useful for search inputs. |
Errors
The Try node runs its try branch. If a node in it throws an error, the catch branch runs with the error message. The finally branch runs in both cases. Throw raises an error yourself. See Node Libraries.
Async operations
The execution flow natively handles async operations. When a node has to wait for a result that takes time (API call, DB query, etc.), the flow pauses until that result is ready; it then resumes with the value available on the node's output.
For JavaScript developers: this is the equivalent of an await on a promise.