App Studio
Set Variable Action
The Set Variable action sets an app variable to a new value, triggering reactive re-renders of all widgets that bind to that variable.
How Reactive Variables Work
App variables are the reactive state of an App Studio application. When a Set Variable action fires:
- The variable's value is updated in the app state
- The Token Resolver marks all token expressions that reference this variable as stale
- All widgets with stale bindings re-evaluate their config and re-render
- DataGrids with variable-based params re-fetch their data
This is how filtering works — a TextInput's onChange sets a searchTerm variable, and a DataGrid bound to {{ variables.searchTerm }} in its params automatically re-fetches filtered data.
Set Variable Action Config
// SetVariableActionConfig
{
"type": "set-variable",
"variable": "selectedStatus", // variable name (declared in app config)
"value": "active" // literal value or token expression
}
// With token expression
{
"type": "set-variable",
"variable": "selectedLeadId",
"value": "{{ row.id }}" // set variable from the clicked row
}
// Set multiple variables (use chain action)
{
"type": "chain",
"actions": [
{ "type": "set-variable", "variable": "filterStatus", "value": "active" },
{ "type": "set-variable", "variable": "filterPage", "value": 1 }
]
}
Declaring App Variables
Variables must be declared in the app configuration before they can be set. In the Properties Editor (with the App root selected), go to the Variables tab:
// App config — variables section
"variables": {
"searchTerm": { "type": "string", "initialValue": "" },
"selectedStatus": { "type": "string", "initialValue": "all" },
"currentPage": { "type": "number", "initialValue": 1 },
"showAdvancedFilters": { "type": "boolean", "initialValue": false }
}
Common Use Cases
| Use Case | Variable | Trigger | Bound To |
|---|---|---|---|
| Search/filter | searchTerm | TextInput onChange | DataGrid params.query |
| Status filter | selectedStatus | Dropdown onChange | DataGrid params.status |
| Selected row context | selectedId | DataGrid onRowSelect | Detail widget params |
| Toggle panel | showSidebar | Button onClick | Sidebar pane visibility expression |
| Error message | errorMsg | onError action | Text widget content |