feat(pwa): Online-Status-Store
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m31s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m31s
Reaktiver Store basierend auf navigator.onLine und den window- Events online/offline. Kein aktives Heuristik-Probing — für unseren Offline-PWA-Use-Case reicht der Browser-Status. Wird von SyncIndicator und require-online-Helper konsumiert. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
14
src/lib/client/network.svelte.ts
Normal file
14
src/lib/client/network.svelte.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
// Reaktiver Online-Status, basierend auf navigator.onLine + events.
|
||||
// Bewusst kein aktives Heuristik-Probing (Test-Fetches) — für unsere
|
||||
// Zwecke reicht der Browser-Status.
|
||||
class NetworkStore {
|
||||
online = $state(typeof navigator === 'undefined' ? true : navigator.onLine);
|
||||
|
||||
init(): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
window.addEventListener('online', () => (this.online = true));
|
||||
window.addEventListener('offline', () => (this.online = false));
|
||||
}
|
||||
}
|
||||
|
||||
export const network = new NetworkStore();
|
||||
Reference in New Issue
Block a user