@jigra/network v5.0.2
@jigra/network
The Network API provides network and connectivity information.
Install
npm install @jigra/network
npx jig sync
Example
import { Network } from '@jigra/network';
Network.addListener('networkStatusChange', status => {
console.log('Network status changed', status);
});
const logCurrentNetworkStatus = async () => {
const status = await Network.getStatus();
console.log('Network status:', status);
};
API
getStatus()
getStatus() => Promise<ConnectionStatus>
Query the current status of the network connection.
Returns: Promise<ConnectionStatus>
Since: 1.0.0
addListener('networkStatusChange', ...)
addListener(eventName: 'networkStatusChange', listenerFunc: ConnectionStatusChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Listen for changes in the network connection.
Param | Type |
---|---|
eventName | 'networkStatusChange' |
listenerFunc | ConnectionStatusChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 1.0.0
removeAllListeners()
removeAllListeners() => Promise<void>
Remove all listeners (including the network status changes) for this plugin.
Since: 1.0.0
Interfaces
ConnectionStatus
Represents the state and type of the network connection.
Prop | Type | Description | Since |
---|---|---|---|
connected | boolean | Whether there is an active connection or not. | 1.0.0 |
connectionType | ConnectionType | The type of network connection currently in use. If there is no active network connection, connectionType will be 'none' . | 1.0.0 |
PluginListenerHandle
Prop | Type |
---|---|
remove | () => Promise<void> |
Type Aliases
ConnectionType
The type of network connection that a device might have.
'wifi' | 'cellular' | 'none' | 'unknown'
ConnectionStatusChangeListener
Callback to receive the status change notifications.
(status: ConnectionStatus): void
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
10 months ago
10 months ago
11 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
11 months ago
11 months ago
12 months ago
11 months ago
11 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
11 months ago
12 months ago
11 months ago
11 months ago
11 months ago
12 months ago
11 months ago
11 months ago
11 months ago
12 months ago
11 months ago
1 year ago
2 years ago