The Action System

Actions in EUIX represent discrete, declarative state transformations or external operations triggered by user events, lifecycle hooks, or timers.


⚡ Built-in Action Types #

Action NameDescriptionKey Child Tags / Attributes
SET_STATEUpdates a state path with a given value or expression.<path>, <value>
MUTATE_STATEPerforms granular array operations (PUSH, REMOVE, SWAP, etc.).<path>, <operation>, <value>, <where>
TOGGLE_STATEInverts a boolean state value.<path>
XHR / FETCHPerforms an asynchronous HTTP REST request.<url>, <method>, <target>, <body>, <headers>
REVALIDATE_APIRe-executes a registered SWR endpoint by ID or tag.tag="..."
NAVIGATENavigates client-side router to a new URL path.to="...", replace="true"
RUN_SCRIPTExecutes sandboxed JavaScript with injected context.Script body text

🛠️ Real-World Multi-Step Action Example #

Here is a practical example showing state setting, conditional mutation, and network fetching combined:

XML
<uid_spec>
  <data_model>
    <state id="isLoading" type="boolean">false</state>
    <state id="errorMessage"></state>
    <state id="articles" type="array">[]</state>
  </data_model>

  <flex direction="column" gap="12">
    <!-- Refresh Button -->
    <button class="btn" disabled="{data.isLoading}">
      <!-- 1. Set loading indicator -->
      <on_click action="SET_STATE">
        <path>data.isLoading</path>
        <value>true</value>
      </on_click>
      
      <!-- 2. Fetch remote articles -->
      <on_click action="XHR">
        <method>GET</method>
        <url>https://api.example.com/articles</url>
        <target>data.articles</target>
      </on_click>
      
      <!-- 3. Reset loading indicator -->
      <on_click action="SET_STATE">
        <path>data.isLoading</path>
        <value>false</value>
      </on_click>

      {data.isLoading ? 'Fetching...' : 'Reload Articles'}
    </button>
  </flex>
</uid_spec>

🧭 Next Step #

Learn how to bundle multi-step sequences into reusable named subroutines in Action Composer.

2 min read · Updated