network-heart-service
v0.1.2
Published
A Service to handle netowrk change.
Readme
Network heart service
A Service to check and handle network change.
How to use
Npm
$ npm install network-heart-service -save// es6
import NetworkHeartService from 'network-heart-service';
this.networkHeartService = new NetworkHeartService({
heartMode: 'auto',
reconnect() {
console.log('TODO ...')
}
});
this.networkHeartService.start();config
heartMode{ number } 2000 if it is undefined , it means useautomode. It will check the network in an incerasing timeout. But is is set with a number, it will check the network in speciy time.lowSpeedNetwork{ function }A function will be fire when your network could work but in low network bandwidth
reconnect{ function }A function will be fire when your network could work.
offline{ function }A function will be fire when your network go to offline
API
isOnline
Check if your network could work.
const isOnline = await NetworkHeartService.isOnline();start() and stop()
Start or Stop the network check service.
this.networkHeartService = new NetworkHeartService({
heartMode: 'auto',
reconnect() {
console.log('TODO ...')
}
});
this.networkHeartService.start();
// this.networkHeartService.stop();Contributions
Your contributions and suggestions are welcome 😄😄🌺🌺🎆🎆
