Iyongbudiarso / v-offline

:electric_plug: Simple VueJS component to detect offline & online changes.

Home Page:https://we-online.site

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

V-Offline ⚑ Build Status github release npm version Build Status npm downloads

  • Detect offline & online events for your vue app.

  • This is on GitHub so let me know if I've b0rked it somewhere, give me a star ⭐ if you like it 🍻

  • Demo here -> πŸ’― Webpackbin Link

Requirements

βœ… Install πŸ‘Œ

npm install v-offline
// or
yarn add v-offline

βœ… Usage πŸŽ“

Register the component globally:

Vue.component('detectNetwork', require('v-offline'));

Or use locally

import detectNetwork from 'v-offline';

βœ… Example 1 πŸ€

<detect-network v-on:detected-condition="detected">
	<div slot="online">Your Online Content!</div>
	<div slot="offline">Your Offline Content!</div>
</detect-network>
Vue.component('example-component', {
	data() {
		return {
			state: null,
		}
	},
	methods: {
		detected(e) {
			this.state = e;
		}
	}
});

βœ… Example 2 πŸ€

<detect-network>
	<div slot="online">Your Online Content!</div>
	<div slot="offline">Your Offline Content!</div>
</detect-network>

βœ… πŸ“– Props

Name Type Required? Description
onlineClass String No Styling the div which you want to give if you're online.
offlineClass String No Styling the div which you want to give if you're offline.

βœ… πŸ‘‚ Events

Name Description
detected-condition Emits an Boolean value which can be used for multiple purposes in your app.

NPM :octocat:

NPM

About

:electric_plug: Simple VueJS component to detect offline & online changes.

https://we-online.site

License:MIT License


Languages

Language:JavaScript 74.2%Language:Vue 25.8%