SvApp singleton initialization sequence, extension points, runtime environment hooks, user alert routing, and UI readiness promises.
SvApp is the application singleton. It owns the persistent object pool, root model object graph, and top-level user interface (SvUserInterface). Subclasses override a small set of hook methods to initialize application models and user interfaces in a clean, predictable order.
| Hook Method | When Executed | Purpose & Usage |
|---|---|---|
setupModel() | Object pool store is open; root model exists. | Initialize application data models; create or fetch top-level subnodes. |
setupUi() | Model object graph is ready. | Customize top-level UI presentation and window settings. |
appDidInit() | Everything is wired up and live. | Post-initialization tasks; posts "appDidInit" notification. |
afterAppUiDidInit() | UI elements are mounted and visible. | Parse URL search parameters via handleSearchParams(params). |
handleSearchParams(params) | Called automatically from afterAppUiDidInit(). | Process URL query parameters for deep-linking. |
rootSubnodeWithTitleForProto):To instantiate top-level application root nodes safely across reloads:
setupModel () {
super.setupModel();
// Creates on first run; reuses from storage on subsequent loads
this._tasksNode = this.rootSubnodeWithTitleForProto("Tasks", TaskManagerNode);
}didInitPromise)Code that needs to wait for complete application setup awaits didInitPromise():
await SvApp.shared().didInitPromise();
// App is now fully initialized and livepromiseUserInterfaceReady)UI-dependent code (e.g. sending navigation selection requests) awaits promiseUserInterfaceReady():
const ui = await SvApp.shared().promiseUserInterfaceReady();
if (ui.providesNavigation()) {
// Safe to send navigation requests
this.postNoteNamed("onRequestSelectNodePath", { path: ["Workspace", "Tasks"] });
}SvApp captures environment lifecycle signals and translates them into environment-agnostic hooks on SvModel:
Model Hook Method (SvModel) | Browser Signal Event | Headless Signal Event | Purpose & Action |
|---|---|---|---|
onAppDidGoOnline() | online event | — | Network connectivity restored |
onAppDidGoOffline() | offline event | — | Network connectivity lost |
onAppWillSuspend() | visibilitychange (hidden) | — | App backgrounded; flush volatile state |
onAppWillTerminate() | beforeunload (sync) | SIGTERM / SIGINT | Shutdown/unload cleanup. Return true to block unload. |
Domain models request user notifications without referencing UI or DOM classes:
this.postNoteNamed("onRequestUserAlert", {
name: "syncFailure",
title: "Sync Error",
message: "Failed to sync changes with cloud store.",
level: "error" // "info" | "warning" | "error"
});SvUserInterface observes onRequestUserAlert. In the browser (SvWebUserInterface), it opens an SvPanelView overlay; in headless Node.js, it logs the alert to console.