-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
If someone wants to PR this or make it better, that'd be cool
const OnLine = resource(({ on }) => {
let online = cell(navigator.onLine);
let cleanup = new AbortController();
let signal = cleanup.signal;
window.addEventListener("offline", (e) => online.current = 'you are offline', { signal });
window.addEventListener("online", (e) => online.current = 'you are online', { signal });
on.cleanup(() => signal.abort());
return () => online.current;
});Usage:
{{ OnLine }}or
class Foo {
@use online = OnLine;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels