Lowdefy
v3.23.3/Actions/SetState/

SetState

(toSet: object): void

The SetState action sets values in state. It takes an object as parameters, and sets each of those values to the state object. This is useful if you want to initialize state, set a flag after an action has executed (eg. to disable a button), or to set the result of a request to state.

Parameters

object

Object with key value pairs to set in state.

Examples

Set a single value to state:
- id: single_value
  type: SetState
  params:
    message: Hello
Set multiple values to state:
- id: multiple_values
  type: SetState
  params:
    firstName: Monica
    lastName: Geller
    address:
      street: 90 Bedford St
      city: New York
      zipCode: '10014'
      country: US
    friends:
      - Ross Geller
      - Rachel Green
      - Chandler Bing
      - Phoebe Buffay
      - Joey Tribbiani
Using dot notation:
- id: dot_notation
  type: SetState
  params:
    firstName: Monica
    lastName: Geller
    address.street: 90 Bedford St
    address.city: New York
    address.zipCode: '10014'
    address.country: US
    friends.0: Ross Geller
    friends.1: Rachel Green
    friends.2: Chandler Bing
    friends.3: Phoebe Buffay
    friends.5: Joey Tribbiani
Initialize state with the value of a request:
- id: initialize
  type: SetState
  params:
    _request: getUser