Component
io.eezo.live.Component
A live component: server-held state, rendered to HTML, updated over patches.
The mental model is a server template that re-renders itself (design/live.md §1): an event arrives from the browser or a Topic, the state moves, render runs again, and the differ ships the difference. The three methods are the three phases, and what each receives is what that phase may do — the split is enforced by the arguments, not by documentation:
- init runs once, at mount, and is the only place subscriptions exist: it receives the Init context, and
subscribeafterinitreturns throws.renderruns on every event, so a subscription there would be a duplicate per re-render. - handle moves the state. It runs on the page's own thread, one event at a time, so it needs no synchronisation of its own. Database work happens here the way it does in any handler: open a scope with
transact { ... }orread { ... }per event — the installedDatabasereaches every thread, and a connection captured across events is already a loud error (EscapedScope). - render is a pure function of the state and receives nothing else. Exactly one root element, in canonical form; the differ refuses anything else by naming the broken rule.
State is any immutable value the component chooses. It lives on the server, owned by one page thread; the browser only ever holds its rendering.
Attributes
- Source
- Component.scala
- Graph
-
- Supertypes
Members list
In this article