Set App State

The Set App State action allows you to update the global application state. This is useful for managing state that affects the entire app or multiple components, enabling centralized control over app-wide data.

Properties

Property
Type
Required
Description

State Updates

Array

Yes

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

Use Cases

  • User Authentication: Manage login status and user data globally

  • Theme Management: Control app-wide theme and appearance settings

  • Language Settings: Store user language preferences across the app

  • Shopping Cart: Maintain cart state across different pages

  • App Configuration: Store feature flags and configuration settings

  • User Preferences: Save user choices and settings globally

Default Behavior

By default:

Behavior
Description

Global Scope

Updates affect all parts of the app

Persistence

State changes persist until app restart

No UI Rebuild

UI updates only when components subscribe to changes

Multiple Updates

All state updates are applied in sequence

Expression Evaluation

All Value expressions are evaluated before updating

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 (login, settings change, etc.)

  2. Select Set App State from the action list

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

  4. Set the corresponding Value for each state variable

  5. Click Add New to add additional state updates as needed

Implementation Details

The action uses DUIAppState().update() to modify global application state. Changes are immediately available throughout the app and persist until the app is restarted.

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

Example native code usage:


Last updated