Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-offline

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-offline

Online/Offline events and directives for vue application

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
increased by7.06%
Maintainers
1
Weekly downloads
 
Created
Source

License: MIT

Offline/online states for Vue applications

This plugins notifies your application when online/offline status changes and allows to conditionally display components depending on the network status. Supports SSR.

Installation

npm install vue-offline --save
import Vue from 'vue'
import VueOffline from 'vue-offline'

Vue.use(VueOffline)

Features

  • v-online directive - shows component only when online
  • v-offline directive - shows component only when offline
  • online event - available in every component, emitted when user changes from offline to online
  • offline event - available in every component, emitted when user changes from online to offline

Example

<template>
  <div id="app">
    <div v-online>This part is visible only when user is online</div>
    <div v-offline>This part is visible only if user is offline</div>
    <div> {{ onlineState }} </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      onlineState: navigator.onLine
    }
  },
  created () {
    this.$on('online', function () {
      this.onlineState = "I'm online now!" 
    })
    this.$on('offline', function () {
      this.onlineState = "I'm offline now!"
    })
  }
}
</script>

Keywords

FAQs

Package last updated on 02 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc