New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-async-helper

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-async-helper

vuejs handling component loading state helper

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

Vue Async Helper

npm npm

Big thanx to @LinusBorg.

Installation

npm install vue-async-helper --save

Usage

  • assign the function to the window so you can use it everywhere without re-importing

    import VAC from 'vue-async-helper'
    window.VueAsyncComponent = VAC
    
  • now replace the () => import(...) call with VueAsyncComponent(import(...))

    /* global */
    Vue.component('MyComp', () => import('abc.vue'))                // before
    Vue.component('MyComp', VueAsyncComponent(import('abc.vue')))   // after
    
    /* local */
    components: {
        MyComp: () => import('abc.vue')                // before
        MyComp: VueAsyncComponent(import('abc.vue'))   // after
    },
    
    propdefaultdescription
    loading"Please Stand By..."A component to use while the async component is loading
    error"Something Went Wrong, Plz Try Again"A component to use if the load fails
    delay200Delay before showing the loading component "in ms"
    timeout5000The error component will be displayed if a timeout is provided and exceeded "in ms"

Changing the helper defaults

  • you can change the default options per call like

    Vue.component('MyComp', VueAsyncComponent(import('abc.vue'), {
        timeout: 1000
    }))
    
  • or globally

    • first create a new file with the below

      // vac.js
      import VAC from 'vue-async-helper'
      window.VueAsyncComponent = (item) => {
          return VAC(item, {
              loading: LoadingComp,
              error: ErrorComp,
              delay: 500,
              timeout: 2000
          })
      }
      
    • next require that file and follow the usage as normal

      // app,js
      require('vac.js')
      
      Vue.component('MyComp', VueAsyncComponent(import('abc.vue')))
      

Keywords

FAQs

Package last updated on 22 Aug 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