XTend Documentation
Enable dark mode

XTend Developer Center

Build with XTend today

RMT Reference: State, Selectors and Data

This page describes data sources, state and declarative derivations.

Syntax

OperatorFormAllowed contextsParametersFunctionDiagnosticsRelated operators
typestate app.count type numberstate, inputtype nameDeclares the expected value type.Missing types produce syntax diagnostics.state, input
initialinitial true or initial { text "Ready" }stateliteral or initial blockSets the initial value.State blocks allow only initial values.preserve
preservestate app.status type object preservestate, surfaceflag without valuePreserves state or surface state across lifecycle boundaries.Wrong contexts produce context diagnostics.destroy releases
fromfrom state app.statusselector, datasource, operations, payloadsource kind and referenceBinds a declarative source.Source kind must be allowed.endpoint, selector, payload
endpointfrom endpoint "/api/items"datasource, operationsstring or identifierBinds host endpoint data.Invalid source kinds are reported.method, contract
ssestream feed from sse app.feedstreamstream identifierBinds Server-Sent Events to streaming.stream requires a source.stream
workerprewarm index from worker search.prepareoperations, datasourceworker identifierDescribes worker-based preparation.Source kind must be static.prewarm
fixturefallback fixture app.sampledatasource, operationsfixture identifierBinds test or fallback data.Unknown references are reported semantically.fallback
resourcefrom resource app.fileoperations, resourceresource identifierUses an owner-scoped resource as source.Missing resources produce semantic diagnostics.resource, dispose
wherewhere item.active == trueselectordeclarative expressionFilters selector results.Function calls are not allowed.find, sort by
findfind item.id == input.idselectordeclarative expressionSelects one record.Invalid expressions are parser diagnostics.where
sort bysort by item.createdAt descselectorpath, directionSorts selector results stably.Sort clause must be complete.output
outputoutput MessageListselectortype nameNames the output contract.Missing type produces syntax diagnostics.selector
methodmethod GETdatasourceHTTP method or identifierDocuments the host method.Only valid in datasource blocks.endpoint
contractcontract "xtend.schema.v1"datasourcestatic stringBinds a data or endpoint schema.Wrong context is reported.result
resultresult listdatasourceresult shapeDescribes the expected result shape.Datasource clause only.fallback
fallbackfallback fixture app.emptydatasource, remote surfacekind and referenceDeclares a safe replacement path.Missing reference is reported.fixture, fallback surface

Allowed contexts

State clauses belong in state, selector clauses in selector, datasource clauses in datasource. Source kinds appear after from or fallback.

Parameters

Identifiers reference records; strings describe external paths or contracts; directions such as asc and desc remain static.

Description

RMT separates stored state, derived view models and host data sources. This lets the compiler understand dependencies without evaluating host JavaScript.

Examples

template reference.data {
  state app.filter type object preserve {
    initial {
      text "open"
    }
  }

  datasource tickets from endpoint "/api/tickets" {
    method GET
    contract "xtend.ticket-list.v1"
    result list
    fallback fixture tickets.empty
  }

  selector openTickets from datasource tickets {
    where ticket.status == "open"
    find ticket.id == app.filter.text
    sort by ticket.createdAt desc
    output TicketList
  }

  portal app.root root "#app" layer surface
  surface list kind region component x-summary {
    portal app.root
    lane visible weight 70 {
      hydrate ticket.list from selector openTickets
    }
  }
}

Diagnostics

The parser reports wrong clauses in each block. The semantic graph reports unknown state, selector, datasource, fixture or resource references.

state, selector, datasource, action, hydrate, stream, when.

The RMT reference index links state, selector, and data records to their lifecycle rules. Related article

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