1.0.0 • Published 4 years ago

universal-network v1.0.0

Weekly downloads
8
License
-
Repository
-
Last release
4 years ago

npm

Network status and monitoring.

Support

Install

$ npm install universal-network --save

Methods

getType(options)

Gets the current network state.

Success return

PropertyTypeDescriptionSupport
networkTypeStringNetwork type
networkAvailableBooleanAvailability of network

onStatusChange(callback)

Start listening for changes in network status.

Callback return

PropertyTypeDescriptionSupport
isConnectedBooleanAvailability of network
networkTypeStringNetwork type

offStatusChange(callback)

Cancels all event monitoring if the parameter is empty.

Parameters

PropertyTypeDefaultRequiredDescriptionSupport
callbackFunctionxCallback 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

4 years ago

1.0.0-beta.1

4 years ago