RMT Reference: Actions und Events
Actions beschreiben State-Änderungen, Effects und emittierte Events. Event Bindings verbinden DOM- oder Surface-Ereignisse mit Actions.
Syntax
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.
Related operators
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