Builds reactive real-time backends on the iii engine. Use when building event-driven apps where state changes automatically trigger side effects, clients receive live updates via streams or websockets, or you need a real-time database layer with pub/sub and CRUD endpoints.
Comparable to: Convex, Firebase, Supabase, Appwrite
Use the concepts below when they fit the task. Not every reactive backend needs every trigger or realtime surface shown here.
state::set, state::get, state::update, state::delete, state::listHTTP CRUD endpoints
→ `state::set`, `state::update`, `state::delete` (writes to 'todos' scope)
↓ (automatic state triggers)
→ on-change → stream::send (push to clients)
→ update-metrics → state::update (aggregate counters)
HTTP GET /metrics → reads from 'todo-metrics' scope
WebSocket clients ← stream 'todos-live'
| Primitive | Purpose |
|---|---|
registerWorker | Initialize the worker and connect to iii |
registerFunction | CRUD handlers and reactive side effects |
trigger({ function_id: 'state::...', payload }) | Database layer |
registerTrigger({ type: 'state', config: { scope } }) | React to any change in a scope |
trigger({ ..., action: TriggerAction.Void() }) | Fire-and-forget stream push to clients |
registerTrigger({ type: 'http' }) | REST endpoints |
See ../references/reactive-backend.js for the full working example — a real-time todo app with CRUD endpoints, automatic change broadcasting via streams, and reactive aggregate metrics.
Code using this pattern commonly includes, when relevant:
registerWorker(url, { workerName }) — worker initializationstate::set, state::get — CRUD via state moduleregisterTrigger({ type: 'state', function_id, config: { scope } }) — reactive side effects on state changeasync (event) => { const { new_value, old_value, key } = event }trigger({ function_id: 'stream::send', payload, action: TriggerAction.Void() }) — push live updates to clientsconst logger = new Logger() — structured logging inside handlersUse the adaptations below when they apply to the task.
event argument (new_value, old_value, key) to determine what changedtodos)ws://host:port/stream/{stream_name}/{group_id}registerFunction (especially with endpoint lists like { path, id } plus iteration), prefer iii-http-invoked-functions.iii-reactive-backend when state scopes, state triggers, and live stream updates are the core requirement.iii-reactive-backend in the iii engine.