npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-real-lazy

v1.0.2

Published

Lazy loading is easy peasy in Vue.js.

Downloads

4

Readme

VueRealLazy

It's a very candide component for Vue.js for realize lazy loading as easy as it possible.

Dictionary

Loader - It's what you show when your component is loading.
Target - It's your component which you want to hide and show your loader while component is loading some data.

Installation

$ npm install vue-real-lazy

Usage

Import Plugin

import VueRealLazy from "vue-real-lazy";

Vue.use(VueRealLazy);

Use this in component like this

With event from child (good approach)

This is a standard case for use lazy loading. You have only two slot section - loader and target. Just define event in your component which will be signal when loader is needed. Emit this loader with true of false state accordingly.

<vue-real-lazy>
  <template v-slot:loader>
    Loader for test-lazy-component
  </template>
  <template v-slot:target="{showLoader}">
    <test-lazy-component @need-loader="showLoader($event)"></test-lazy-component>
  </template>
</vue-real-lazy>

Explicit passing function (bad approach)

This approach is bad, but it can be used if you want (it is not recommended to use because it's antipattern)

<vue-real-lazy>
  <template v-slot:loader>
    Loader for test-lazy-component
  </template>
  <template v-slot:target="{showLoader}">
    <test-lazy-component :show-loader="showLoader"></test-lazy-component>
  </template>
</vue-real-lazy>

After passing this function in component as a prop you can explicit call it to show or hide loader.

this.showLoader(false); // this hides loader

No restrictions

No restrictions in markup, you can use a component as a loader, also you can use regular html tag as a target.

Use a component as a loader:

<vue-real-lazy>
  <template v-slot:loader>
    <custom-loader></custom-loader>
  </template>
  <template v-slot:target="{showLoader}">
    <test-lazy-component2 @need-loader="showLoader($event)"></test-lazy-component2>
  </template>
</vue-real-lazy>

Use a regular tag img as a target for lazy loading (this works fine and easy):

<vue-real-lazy>
  <template v-slot:loader>
    My Custom loader
  </template>
  <template v-slot:target="{showLoader}">
    <img
      :src="`https://site.com/img.jpg`"
      alt="My cool image"
      @load="showLoader(false)"
    >
  </template>
</vue-real-lazy>