XTend Dokumentation
Dunkelmodus aktivieren

XTend Developer Center

Build with XTend today

RMT Reference: Actions und Events

Actions beschreiben State-Änderungen, Effects und emittierte Events. Event Bindings verbinden DOM- oder Surface-Ereignisse mit Actions.

Syntax

OperatorFormAllowed contextsParametersFunctionDiagnosticsRelated operators
inputinput id stringactionName, TypDeklariert Action-Payload-Felder.Fehlende Typen werden gemeldet.payload
statusstatus app.requestactionState-PfadBindet Loading-, Success- und Error-Status.Unbekannter State wird semantisch gemeldet.effect
effecteffect fetch datasource ticketsactionEffect-Art, optionale QuelleDeklariert host-owned asynchrone Arbeit oder einen festen Component-Command.Effect-Quelle muss datasource, resource oder selector sein. Component-Commands akzeptieren nur focus, reset und snapshot.on success ->
reducereduce state.app.status.text = "Saved"actionZielpfad, AusdruckSchreibt deklarativ in State.Actions ohne Reducer können blockiert werden.state, status
emitemit app.saved with id input.idactionEventname, optionale PayloadVeröffentlicht ein typisiertes RMT-Event.Fehlende Payload-Contracts können semantisch gemeldet werden.with, emits
withwith id input.idemitSchlüssel/Wert-PaareMappt Event-Payload direkt aus Action-Input oder State.Ungültige Payload-Werte erzeugen Syntaxfehler.payload
onon click -> action savesurface, Policy-Block, Action-ResultEvent oder PhaseBindet Ereignisse oder Action-Ergebnisse.-> und action sind bei Event Bindings erforderlich.target, payload
targeton input target email -> action saveEvent BindingZiel-IdentifierSchränkt das Event Binding auf ein Ziel ein.Ziel muss ein Identifier sein.on
-> actionon click -> action saveEvent BindingAction-IdentifierVerknüpft Ereignis und Action.Das Keyword action ist Pflicht.on, payload
payloadpayload id from target.dataset.idEvent-Payload-BlockName und Source-PfadMappt DOM-, Detail- oder Surface-Kontext in Action-Input.Payload-Blöcke erlauben nur payload und preventDefault.from, input
preventDefaultpreventDefault trueEvent-Payload-BlockBooleanDokumentiert, dass der Host das native Default-Verhalten verhindert.Nur im Event-Payload-Block erlaubt.payload
on success -> reduceon success -> reduce state.app.status.text = result.textactionPhase, EffekttextBeschreibt Result-Handling nach erfolgreichem Effect.Result-Handler brauchen ->.effect, reduce
on success -> emiton success -> emit app.loadedactionPhase, EffekttextEmittiert ein Event nach Erfolg.Payload-Shape kann separat geprüft werden.emit
on error -> overlayon error -> overlay app.toastactionPhase, Overlay-ReferenzBindet Fehlerfeedback an ein Overlay.Overlay-Referenz muss existieren.overlay

Allowed contexts

input, status, effect, reduce, emit und Action-Result-Handler stehen in action. Event Bindings stehen in surface oder in Policy-Blöcken von Lifecycle-Operationen.

Parameters

Eventnamen, Actionnamen und Payload-Schlüssel sind Identifier. Payload-Werte sind Pfade wie input.id, detail.value, target.dataset.id oder surface.id.

Description

Actions sind deklarative Übergänge. Sie beschreiben, was geändert oder veröffentlicht werden soll; der Host entscheidet, wie konkrete Adapter ausgeführt werden.

Component-Commands

Eine Action darf die öffentlichen Methoden einer geeigneten, statisch bekannten Surface über genau diese Formen aufrufen:

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 {
  }
}

selector ist hier die Autorisierungsform für eine statische Surface-ID; der Compiler löst sie auf ein surface-Ziel mit Component-Typ auf. Derzeit ist dieser Vertrag für x-textarea und ausschließlich für focus(), reset() und snapshot() freigegeben. Unbekannte Surfaces, ungeeignete Components, andere Source-Arten und beliebige Methodennamen sind harte Compilerfehler mit Source-Range.

Maraca führt den Command nach Rendern und Hydration innerhalb des Orchestrierungs-Roots aus. Es gibt keinen Document-Fallback und keinen Zugriff auf Shadow Roots. Das Action-Ergebnis bleibt in XTendMaraca.orchestration.snapshot().actions[] sichtbar. effects[].value.result hat den Vertrag xtend.maraca.component-command-result.v1 mit command, surfaceId, component und result; bei focus und reset ist result null, bei snapshot enthält es den öffentlichen XTextarea-Snapshot. Ein Component-Command verändert nicht automatisch RMT-State.

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

Falsche Action-Clauses, fehlende Reducer, unbekannte Overlay-Referenzen, ungültige Component-Commands und fehlende Payload-Contracts werden vom Parser, Linter, Compiler oder Semantic Graph gemeldet.

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

Weiterführend

Der RMT-Referenzindex ordnet Action- und Event-Records in das vollständige Sprachmodell ein. Verwandter Artikel

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