XTend Documentation
Enable dark mode

XTend Developer Center

Build with XTend today

RMT Reference: Actions and Events

Actions describe state changes, effects and emitted events. Event bindings connect DOM or surface events to actions.

Syntax

OperatorFormAllowed contextsParametersFunctionDiagnosticsRelated operators
inputinput id stringactionname, typeDeclares action payload fields.Missing types are reported.payload
statusstatus app.requestactionstate pathBinds loading, success and error status.Unknown state is semantic diagnostic.effect
effecteffect fetch datasource ticketsactioneffect kind, optional sourceDeclares host-owned asynchronous work or a fixed component command.Effect source must be datasource, resource or selector. Component commands accept only focus, reset and snapshot.on success ->
reducereduce state.app.status.text = "Saved"actiontarget path, expressionWrites declaratively to state.Actions without reducers can be blocked.state, status
emitemit app.saved with id input.idactionevent name, optional payloadPublishes a typed RMT event.Missing payload contracts may be reported semantically.with, emits
withwith id input.idemitkey/value pairsMaps event payload directly from action input or state.Invalid payload values produce syntax errors.payload
onon click -> action savesurface, policy block, action resultevent or phaseBinds events or action results.-> and action are required for event bindings.target, payload
targeton input target email -> action saveevent bindingtarget identifierNarrows the event binding to one target.Target must be an identifier.on
-> actionon click -> action saveevent bindingaction identifierConnects event and action.The action keyword is required.on, payload
payloadpayload id from target.dataset.idevent payload blockname and source pathMaps DOM, detail or surface context into action input.Payload blocks allow only payload and preventDefault.from, input
preventDefaultpreventDefault trueevent payload blockbooleanDocuments that the host prevents native default behavior.Only valid in event payload blocks.payload
on success -> reduceon success -> reduce state.app.status.text = result.textactionphase, effect textDescribes result handling after a successful effect.Result handlers require ->.effect, reduce
on success -> emiton success -> emit app.loadedactionphase, effect textEmits an event after success.Payload shape can be checked separately.emit
on error -> overlayon error -> overlay app.toastactionphase, overlay referenceBinds error feedback to an overlay.Overlay reference must exist.overlay

Allowed contexts

input, status, effect, reduce, emit and action result handlers belong in action. Event bindings belong in surface or lifecycle policy blocks.

Parameters

Event names, action names and payload keys are identifiers. Payload values are paths such as input.id, detail.value, target.dataset.id or surface.id.

Description

Actions are declarative transitions. They describe what should change or publish; the host decides how concrete adapters run.

Component commands

An action may call public methods on an eligible, statically known surface through exactly these forms:

template reference.componentCommands {
  state editor.command type object preserve {
    initial {
      last "idle"
    }
  }

  action editor.focus {
    effect focus selector maraca.testbench.editor
    reduce state.editor.command.last = "focus"
  }

  action editor.reset {
    effect reset selector maraca.testbench.editor
    reduce state.editor.command.last = "reset"
  }

  action editor.capture {
    effect snapshot selector maraca.testbench.editor
    reduce state.editor.command.last = "snapshot"
  }

  surface maraca.testbench.editor kind field component x-textarea {
  }
}

Here, selector is the authoring form for a static surface ID; the compiler resolves it to a surface target with a component type. This contract currently permits x-textarea and only focus(), reset() and snapshot(). Unknown surfaces, ineligible components, other source kinds and arbitrary method names are hard compiler errors with a source range.

Maraca runs the command after rendering and hydration, within the orchestration root. It has no document fallback and does not traverse shadow roots. The action result remains visible in XTendMaraca.orchestration.snapshot().actions[]. effects[].value.result uses schema xtend.maraca.component-command-result.v1 with command, surfaceId, component and result; focus and reset return null, while snapshot contains the public XTextarea snapshot. A component command does not mutate RMT state automatically.

Examples

template reference.actions {
  state app.status type object preserve {
    initial {
      text "Idle"
    }
  }

  datasource tickets from endpoint "/api/tickets" {
    method GET
  }

  action saveTicket {
    input id string
    status app.status
    effect fetch datasource tickets
    reduce state.app.status.text = "Saving"
    on success -> reduce state.app.status.text = "Saved"
    on success -> emit ticket.saved
    on error -> overlay app.toast
    emit ticket.requested with id input.id
  }

  portal app.root root "#app" layer surface
  overlay app.toast kind toast portal app.root

  surface editor kind form component x-form {
    portal app.root
    lane user-blocking weight 88 {
      mount editor.form from endpoint ticket.editor {
        on submit target editor -> action saveTicket {
          payload id from target.dataset.ticketId
          preventDefault true
        }
      }
    }
  }
}

Diagnostics

Wrong action clauses, missing reducers, unknown overlay references, invalid component commands and missing payload contracts are reported by parser, linter, compiler or semantic graph.

action, state, datasource, overlay, surface, on, emit.

The RMT reference index places action and event records in the complete language model. Related article

(c) 2026 - CCS Networks | Powered by XRouter PHP Extension