universal-network
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

npm

Network status and monitoring.

Support

miniApp wechatMiniprogram

Install

$ npm install universal-network --save

Methods

getType(options)

Gets the current network state.

Success return

Property Type Description Support
networkType String Network type miniApp wechatMiniprogram
networkAvailable Boolean Availability of network miniApp

onStatusChange(callback)

Start listening for changes in network status.

Callback return

Property Type Description Support
isConnected Boolean Availability of network miniApp wechatMiniprogram
networkType String Network type miniApp wechatMiniprogram

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 miniApp

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);

Readme

Keywords

Package Sidebar

Install

npm i universal-network

Weekly Downloads

1

Version

1.0.0

License

none

Unpacked Size

14.6 kB

Total Files

38

Last publish

Collaborators

  • rax-publisher
  • zeroling