Vue event bus plugin listening for online/offline changes
AboutWhenever the navigator's connection status changes a 'connection' event is emitted with a boolean payload indicating the new state (online = true, offline = false).
InstallationUsagenpm install --save vue-connection-listener
main.js
import Vue from "Vue";
import bus from "./bus";Â
Â
Vue.prototype.$bus = bus;Â
Â
import VueConnectionListener from "vue-connection-listener";
const connectionListener = new VueConnectionListener(bus);Â
Â
new Vue({
  el: "#app",
  render: h => h(App),
  created() {
    connectionListener.register();
  },
  destroyed() {
    connectionListener.unregister();
  }
});
Inside any component
Notesthis.$bus.$on("connection", online => {
  alert(online ? "You are online ð" : "You are offline ð");
});
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:
import Vue from "vue";
export default new Vue();
For more info:
https://alligator.io/vuejs/global-event-bus/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4