vue-connection-listener
Vue event bus plugin listening for online/offline changes
About
Whenever the navigator's connection status changes a 'connection' event is emitted with a boolean payload indicating the new state (online = true, offline = false).
Installation
npm install --save vue-connection-listener
Usage
main.js
;; // Event bus instance Vueprototype$bus = bus; // Optional (but convenient) ;const connectionListener = bus; // Create instance (injecting our bus) el: "#app" { connectionListener; } { connectionListener; };
Inside any component
this$bus;
Notes
You need to import your own event bus and then inject it as a dependency.
Creating a bus could be as simple as creating a bus.js file with the following contents:
; ;
For more info: