Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@solid-primitives/connectivity

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/connectivity

A navigator.onLine signal.

latest
Source
npmnpm
Version
0.4.3
Version published
Weekly downloads
278
67.47%
Maintainers
3
Weekly downloads
 
Created
Source

Solid Primitives Connectivity

@solid-primitives/connectivity

size version stage

A navigator.onLine signal that tells you when the browser thinks you're online. Connectivity is determined by your browser, which is a best-effort process.

  • makeConnectivityListener - Attaches event listeners and fires callback whenever window.onLine changes.
  • createConnectivitySignal - A signal representing the browser's interpretation of whether it is on- or offline.

Installation

npm install @solid-primitives/connectivity
# or
yarn add @solid-primitives/connectivity

makeConnectivityListener

Attaches event listeners and fires callback whenever window.onLine changes.

import { makeConnectivityListener } from "@solid-primitives/connectivity";

const clear = makeConnectivityListener(isOnline => {
  console.log(isOnline); // T: booelan
});
// remove event listeners (happens also on cleanup)
clear();

Definition

function makeConnectivityListener(callback: (isOnline: boolean) => void): VoidFunction;

createConnectivitySignal

A signal representing the browser's interpretation of whether it is on- or offline.

import { createConnectivitySignal } from "@solid-primitives/connectivity";

const isOnline = createConnectivitySignal();
isOnline(); // T: boolean

useConnectivitySignal

This primitive provides a singleton root variant that will reuse event listeners and signals across dependents.

It's behavior is the same as createConnectivitySignal.

import { useConnectivitySignal } from "@solid-primitives/connectivity";

const isOnline = useConnectivitySignal();
isOnline(); // T: boolean

Definition

function createConnectivitySignal(): Accessor<boolean>;

Demo

https://codesandbox.io/s/solid-primitives-connectivity-demo-2m76q?file=/index.tsx

Changelog

See CHANGELOG.md

Keywords

network

FAQs

Package last updated on 30 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts