docs(ui): clarify module-scoped singleton in useBreakpoint

Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
Johan Persson
2026-02-27 11:54:18 +01:00
parent f10b3b8d7d
commit 33324d45ac
+5 -2
View File
@@ -49,9 +49,12 @@ function computeBreakpoint(): Breakpoint {
return 'initial';
}
// --- Singleton store ---
// --- Module-scoped singleton store ---
// This is intentionally not a global singleton. Multiple copies of this module
// (e.g. different package versions or module federation remotes) each get their
// own store. This avoids cross-version coupling at the cost of a few extra
// listeners, which is a fine trade-off.
// `current` is initialized lazily on first client-side access.
// `listeners` is eagerly initialized since Set is safe to create on the server.
let current: Breakpoint | undefined;
const listeners = new Set<() => void>();