Document persistence failure-surfacing and overlay-store conventions

This commit is contained in:
2026-06-05 13:07:55 +03:00
parent 8e80b82cc0
commit 3dd8187ee6
2 changed files with 28 additions and 0 deletions
+14
View File
@@ -162,6 +162,20 @@ Each cohesive feature owns a store holding its durable domain state.
- **`useSettingsStore`** — user preferences (editor options, render debounce,
date format, theme); mirrors what gets persisted to `localStorage`.
### Global overlay stores (imperative trigger)
Some surfaces are summoned from anywhere — including non-React code — and own only
ephemeral request state, not durable data:
- **`useConfirmStore`** — the blocking confirm dialog (the `window.confirm` replacement).
- **`useNotificationStore`** — non-blocking toasts (failed saves, etc.).
Each pairs its store with a thin **imperative trigger** exported alongside the hook —
`confirm(opts): Promise<boolean>` and `notify(opts): string` — so orchestration/services can
raise one without a hook: `export const notify = (o) => useNotificationStore.getState().notify(o)`.
Components subscribe to the store to _render_ it; everyone else calls the function. (Why a
toast at all, and which channel for which message: [10 · Interaction & Feedback](10-interaction-and-feedback.md) §1.)
### The central `useAppStore`
`useAppStore` holds only _cross-cutting, ephemeral UI state_ that no single