ryvan-js / wiremonkey

A javascript realtime internet connection tracker and notifier.
MIT License
13 stars 11 forks source link

Callback Handler for connected and disconnected event? #3

Closed psaung closed 6 years ago

psaung commented 7 years ago

I want to add some callback handler for connected and disconnected event just like as the following.

WireMonkey.on('connected', function(){
  console.log('Your connection is alived.');
});
WireMonkey.on('disconnected', function(){
  console.log('You are disconnected from internet.');
});

Is there any way to hook handler?

ryvan-js commented 7 years ago

Hello there, i regret to say that the plugin doesn't have any event handlers for time being, but there is a workaround,i encourage you to do a simple hack by adding methods under this two function from the plugin file(wiremonkey.js).The plugin more likely will acquire event handlers on its next release,thanks for using the plugin.

For disconnect handler : line 43

_.onDisconnect = function(){
                          .......
                          <your functions here>
            }

For connect handler : line 48

_.onConnect = function(){
                          .......
                          <your functions here>
            }