RMT Reference: Actions and Events
Actions describe state changes, effects and emitted events. Event bindings connect DOM or surface events to actions.
Syntax
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.
Related operators
action, state, datasource, overlay, surface, on, emit.
Related reading
The RMT reference index places action and event records in the complete language model. Related article