todos::on-changed, a function that each browser observes.
Engine configuration
The workers needed to support a browser-driven reactive app:state for storage and an RBAC
listener (rbac-proxy or iii-worker-manager) for browser connections. No streaming worker is
required.
Backend
The worker, auth, storage, change notifications, and CRUD functions that power the app server-side.Worker setup
Connect a worker and register the functions the app needs.Auth function (RBAC)
An auth function runs on each new browser WebSocket connection, issues a session ID, and namespaces the session’s registered functions to prevent collisions. The listener exposestodos::on-changed
to the session so the browser can observe it.
Storage
Todos live in thestate worker under one scope, one key per todo, each with a revision number that
every write increments.
Change notifications
The todo worker registerstodos::on-changed as a private function whose handler returns the change
{ id, revision, op }, and calls it after every committed write. When it runs, the target of each
browser’s observer runs. Its onObserverAdded hook caps the number of browsers that observe it,
rejecting the observer past the cap.
Functions
The CRUD functions the browser calls (create, toggle, delete) write to storage and then calltodos::on-changed. todos::get and a paginated todos::list serve reads.
Frontend
The browser-side WebSocket connection and reactive hook that render live updates.Connection
Connect the browser to the engine over a single WebSocket usingiii-browser-sdk.
Real-time hook
A hook that observestodos::on-changed with a browser function as the target, then loads the list
with todos::list. Each notification re-reads one todo unless the hook already has that revision,
and the hook reloads the list after a reconnect.