Adaptive Region lifecycle
Mount once, render typed intent, observe sanitized state, and dispose all work with the host surface.
A Region is the unit of evaluation, presentation, and cleanup. Newer requests replace older ones only inside the same Region.
When you need this#
- You mount and drive a region through the app API directly.
- You need to watch render status or show your own loading UI.
- You must release all pending work when a screen unmounts.
1. Mount the region once#
app.mount attaches a region to an element and starts container observation. It fetches nothing until you render.
const mounted = app.mount({ target, regionId: 'main', resourceId: 'people' });
if (!mounted.ok) throw new Error(mounted.diagnostics[0].message);
Region IDs are unique within the app. A failed mount returns diagnostics instead of an element.
2. Send a request#
app.render validates the input, reads current authority, compiles, evaluates, picks a view, commits, and returns the outcome.
const receipt = await app.render({
regionId: 'main',
intent: { version: '1', id: 'browse-people', kind: 'browse', resource: 'people' },
});
receipt.status is one of the values in the table below. A newer request in the same region supersedes an older one still in flight.
3. Watch region state#
app.subscribe reports sanitized lifecycle state — phase, result references, and diagnostics — never materialized rows.
const unsubscribe = app.subscribe('main', (state) => renderStatus(state.phase));
4. Dispose all work#
unsubscribe();
app.unmount('main'); // cancel and release one region
app.dispose(); // release every region, listener, and pending render
Calls after dispose fail closed. Dispose is safe to call more than once.
Read the result status#
| Status | Meaning |
|---|---|
renderer-ready | Runtime evidence committed and the renderer accepted the validated presentation — not proof of browser paint or user attention. |
needs-input | The request is valid but needs a user choice or form input. |
denied | Current trusted authority rejected the operation. |
cancelled | A newer render, abort signal, unmount, or disposal superseded the request. |
unsupported | No valid registered contract can perform the request. |
failed | A limited internal or adapter failure occurred; inspect diagnostics and recovery. |
What can go wrong#
- An invalid presentation keeps the previous view while it remains authorized.
- Revocation is different from failure — data the user may no longer see is cleared, not retained.
- A focused or dirty-draft control defers a resize replacement; the newest measurement applies after the guard ends.
