File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,21 @@ export const screenTop = new ReactiveValue(
9696 }
9797) ;
9898
99+ /**
100+ * `online.current` is a reactive view of `navigator.onLine`. On the server it is `undefined`
101+ */
102+ export const online = new ReactiveValue (
103+ BROWSER ? ( ) => navigator . onLine : ( ) => undefined ,
104+ ( update ) => {
105+ const unsub_online = on ( window , 'online' , update ) ;
106+ const unsub_offline = on ( window , 'offline' , update ) ;
107+ return ( ) => {
108+ unsub_online ( ) ;
109+ unsub_offline ( ) ;
110+ } ;
111+ }
112+ ) ;
113+
99114/**
100115 * `devicePixelRatio.current` is a reactive view of `window.devicePixelRatio`. On the server it is `undefined`.
101116 * Note that behaviour differs between browsers — on Chrome it will respond to the current zoom level,
Original file line number Diff line number Diff line change @@ -1995,6 +1995,10 @@ declare module 'svelte/reactivity/window' {
19951995 * `screenTop.current` is a reactive view of `window.screenTop`. On the server it is `undefined`
19961996 */
19971997 export const screenTop : ReactiveValue < number | undefined > ;
1998+ /**
1999+ * `online.current` is a reactive view of `navigator.onLine`. On the server it is `undefined`
2000+ */
2001+ export const online : ReactiveValue < boolean | undefined > ;
19982002 /**
19992003 * `devicePixelRatio.current` is a reactive view of `window.devicePixelRatio`. On the server it is `undefined`.
20002004 * Note that behaviour differs between browsers — on Chrome it will respond to the current zoom level,
You can’t perform that action at this time.
0 commit comments