Reactor Component Structure
Reactor components are typically defined as .hrc files and provide imperative backend logic within an app.
Reactor components follow a common shape:
- Declare input parameters (
param) to define what the ingress must provide. - Transform incoming payloads into structured commands.
- Send the command set to an actor using
messageActor.
They may also query graph state or read values from the registry as part of their logic. Reactor components do not persist state directly. Instead, they emit commands to actors, and the actors are responsible for validating and storing data in the graph.
Input parameters
Parameters define the component’s expected inputs. They can be primitives or nested structures.
param debug: boolean = false
param order: { ... }
param secret: textBuilding actor commands from the payload
Components do not persist state directly. Instead, they assemble the command objects required by an actor.
In Create Your first app, the component creates an order by sending a create message to the order actor. That create message contains the commands needed to build the order.
For example, order lines are created from the incoming cart items:
let orderLineCommands =
order.get.cart
select cartItem =>
let orderLineId = newid
from [
{ type = 'createOrderLine' ... },
{ type = 'setOrderLineTax' ... }
]
flattenDependency chain inside commands
Some commands depend on earlier state.
Order lines require a deliveryId, so delivery must be created first:
let deliveryId = newid
let deliveryCommands =
[[{ type = 'createDelivery', deliveryId = deliveryId }], deliveryAddressCommands]
flattenThe final order message composes both command sets:
commands = [deliveryCommands, orderLineCommands] flattenFor details on Filtrera syntax (match, flatten, select, etc.), see the Filtrera reference.