online binding

pull/14660/head
Simon Holthausen 2 years ago
parent c87d27a990
commit cb2efe6c65

@ -96,6 +96,21 @@ export const screenTop = new ReactiveValue(
}
);
/**
* `online.current` is a reactive view of `navigator.onLine`. On the server it is `undefined`
*/
export const online = new ReactiveValue(
BROWSER ? () => navigator.onLine : () => undefined,
(update) => {
const unsub_online = on(window, 'online', update);
const unsub_offline = on(window, 'offline', update);
return () => {
unsub_online();
unsub_offline();
};
}
);
/**
* `devicePixelRatio.current` is a reactive view of `window.devicePixelRatio`. On the server it is `undefined`.
* Note that behaviour differs between browsers on Chrome it will respond to the current zoom level,

@ -1995,6 +1995,10 @@ declare module 'svelte/reactivity/window' {
* `screenTop.current` is a reactive view of `window.screenTop`. On the server it is `undefined`
*/
export const screenTop: ReactiveValue<number | undefined>;
/**
* `online.current` is a reactive view of `navigator.onLine`. On the server it is `undefined`
*/
export const online: ReactiveValue<boolean | undefined>;
/**
* `devicePixelRatio.current` is a reactive view of `window.devicePixelRatio`. On the server it is `undefined`.
* Note that behaviour differs between browsers on Chrome it will respond to the current zoom level,

Loading…
Cancel
Save