Socket
Socket
Sign inDemoInstall

vue-lazy-components-option

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-lazy-components-option

Provide lazyComponents option for Vue components


Version published
Maintainers
1
Install size
10.2 kB
Created

Readme

Source

vue-lazy-components-option

Provide lazyComponents option for Vue components

Usage

Install it by npm:

$ npm install vue-lazy-components-option

Then you initialize it with Vue constructor:

import Vue from 'vue'
import LazyComponents from 'vue-lazy-components-option'

Vue.use(LazyComponents)

lazyComponents option can be used for your components:

<script>
import Foo from './Foo.vue'
import Bar from './Bar.vue'

export default {
  lazyComponents: () => ({
    Foo,
    Bar
  })
}
</script>

Mixin Usage

You also can partially enable lazyComponents option in a specific component by using a mixin. In this usage, you do not have to register this library globally with Vue.use:

<script>
import { lazyComponentsMixin } from 'vue-lazy-components-option'
import Foo from './Foo.vue'
import Bar from './Bar.vue'

export default {
  mixins: [lazyComponentsMixin],

  lazyComponents: () => ({
    Foo,
    Bar
  })
}
</script>

What is it for?

This small library is meant to be used for dealing with circular dependency among your components.

To avoid that, you can assign your component in beforeCreated hook like Vue.js official docs stated. But it easily bloats your code when the components are increased.

lazyComponents option does the same thing under the hood but its syntax is simpler as it is almost the same interface with components option except that it is a function returning components.

License

MIT

Keywords

FAQs

Last updated on 27 Nov 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc