set-state

The set-state action sets the global state (also called the solution state). Multiple components and jigs can access the state's value across the solution. Effectively managing the global state ensures that all parts of the app that depend on this data are updated consistently. To understand how to use states, see State.

Configuration options

A set-state action can be set up in various ways:

  1. As onFocus action that will be executed.

  2. As onRefresh action that will be executed.

  3. As the main action on the jig, and when you press the action, the set-state action will be executed.

  4. The onPress and onChange actions will be executed when you trigger these events.

Examples and code snippets

set-state as onFocus/onRefresh

Count triggers with set-sate
Count triggers with set-sate

Set state action is used when the onFocus/onRefresh event is triggered and a count is shown of the number of triggers.

See the example in GitHub.

onFocus: 
  type: action.set-state
  options:
    state: [email protected]
    value: [email protected] +1 

set-state as action

Set-state action
Set-state action

Set-state action is used as the primary action on the jig, to set the value of the action-key to +1.

See the example in GitHub.

action.jigx
actions:
  - children:
      - type: action.set-state
        options:
          title: Add 1 to your action-key
          state: [email protected]
          value: [email protected] +1

set-state as onPress/onChange

Set-state onPress/onChange
Set-state onPress/onChange

Set-state action used on the list as onPress/onChange action, to set the value of the key to +1.

See the example in GitHub.

onPress: 
  type: action.set-state
  options:
    state: [email protected]
    value: [email protected] +1

Last updated

Was this helpful?