1.0.0 • Published 6 years ago
universal-network v1.0.0
Network status and monitoring.
Support
Install
$ npm install universal-network --saveMethods
getType(options)
Gets the current network state.
Success return
| Property | Type | Description | Support |
|---|---|---|---|
| networkType | String | Network type | |
| networkAvailable | Boolean | Availability of network |
onStatusChange(callback)
Start listening for changes in network status.
Callback return
| Property | Type | Description | Support |
|---|---|---|---|
| isConnected | Boolean | Availability of network | |
| networkType | String | Network type |
offStatusChange(callback)
Cancels all event monitoring if the parameter is empty.
Parameters
| Property | Type | Default | Required | Description | Support |
|---|---|---|---|---|---|
| callback | Function | x | Callback function for network state change events |
Example
import Network from 'universal-network';
Network.getType().then(res => {
console.log(res.networkType);
});
Network.onStatusChange((res) => {
console.log('on: ', res.networkType)
});
setTimeout(() => {
Network.offStatusChange();
}, 1000);1.0.0
6 years ago
1.0.0-beta.1
6 years ago