An easy way to show if a users browser is online, with support for custom notification drivers. Inspired by Sopamo/vue-online.
See a functioning demo deveo demo site
npm install --save @deveodk/vue-online
import Vue from 'vue'
import vueOnline from '@deveodk/vue-online'
Vue.use(vueOnline)
<!-- From CDN -->
<script src="https://unpkg.com/@deveodk/vue-online"></script>
The package provides multiple options to notfiy if a users browser is online. The easiest way is to let the plugin do it automaticly.
# Using the default notification
import online from '@deveodk/vue-online'
Vue.use(online, {
notifier: require('@deveodk/vue-online/drivers/deveoToastr.js'),
defaultOnlineTitle: 'Online',
defaultOnlineMessage: 'You are online',
defaultOfflineTitle: 'Offline',
defaultOffilneMessage: 'You are offline'
})
# The plugin comes with a build in mixin that allows you to make your own functionality
import {VueOnline} from '@deveodk/vue-online'
export default {
mixins: [VueOnline]
}
This will give you a reactive variable {{VueOnline}}
the variable is either true
for online, or false
for offline