Set State

The Set State action updates the state of a selected state container, page, or component. It allows you to modify specific pieces of state data dynamically, optionally triggering a UI rebuild to reflect these changes immediately.

Properties

Property
Type
Required
Description

State

Dropdown

Yes

Select the state container, page, or component whose state you want to update.

State Updates

Array

No

List of variable updates within the selected state. Each update contains a State Name (dropdown) and Value pair. Use "Add New" button to add multiple updates.

Rebuild UI

boolean

No

Whether to rebuild the UI immediately after the state update. Defaults to false.

Use Cases

  • Form Field Updates: Modify form input values based on user interactions

  • UI State Management: Control visibility, enabled state, or styling of components

  • Data Synchronization: Update state with API response data

  • Interactive Controls: Toggle switches, checkboxes, or selection states

  • Dynamic Content: Change displayed content based on user selections

Default Behavior

By default:

Behavior
Description

State Updates

All updates in the State Updates array are applied atomically

UI Rebuild

When Rebuild UI is false, state changes may not immediately update the UI

Expression Evaluation

All expressions in Value fields are evaluated in the current scope context

Error Handling

Invalid state context names throw an error

How to Use

Call External Method action configuration showing message name and payload fields
Call External Method action configuration in Digia Studio
  1. Attach the action to a widget event (button tap, form submission, etc.)

  2. Select Set State from the action list

  3. Select the State from the dropdown to choose the target state container

  4. In the State Updates section, select a variable State Name from the dropdown for each update

  5. Set the corresponding Value for each variable

  6. Click Add New to add additional variable updates as needed

  7. Optionally enable Rebuild UI for immediate visual updates

Implementation Details

The action requires a StateContextProvider ancestor in the widget tree to locate the specified state context. Each update in the State Updates array specifies a State Name and Value pair.

When Rebuild UI is true, the state context notifies listeners to trigger a UI rebuild. When false, the state is updated but the UI may not immediately reflect changes until the next natural rebuild.

State values can be any type (strings, numbers, booleans, objects, arrays) and support expressions for dynamic evaluation.


Last updated