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

stack-keep-alive-whitelist

v1.0.17

Published

## Introdaction

Downloads

21

Readme

Stack-Keep-Alive

Introdaction

English | 中文

Stack-Keep-Alive is an automatic management tool for page cache in Vue.js (Vue 3.x) project.

Vue2.x Version

Online Demo, Check the Vue-devtools Panel

img

Why do you need this plugin

The built-in keep-alive component is very useful in development, but it is not intelligent enough, it is difficult to clean up the page cache later, you need to use exclude and include API to save memory, and it cannot be accurately destroyed for different pages created by the same component.

If you have experienced mobile native development, you will not be troubled by this problem, because the model similar to NavigationController to manage each page is a stack structure, and the top page of the stack is destroyed when returning back.(The API is push and pop )

Features

  1. Automatically detect forward or backward
  2. Automatically destroy the current page cache when routing back
  3. Automatically create a new cache instance when routing forward, regardless of whether the component is cached or not
  4. After refreshing the page, it is still able to accurately identify forward or backward
  5. replaceStay whitelist helps cache pages when tab switching
  6. singleton allows you to set a globally unique page instance
  7. sk-transition allows you to use two animations to simulate the native stacking effect

Usage

  1. npm i -s stack-keep-alive | yarn add stack-keep-alive
  2. Replace the keep-alive component with stack-keep-alive (no need to import, registered global component)
<router-view v-slot="{ Component }">
  <stack-keep-alive v-slot='{ key }'> 
      <component :is="Component" :key='key'/>
  </stack-keep-alive>
</router-view>
  1. When the app is initialized, use the StackKeepAlive plugin
import StackKeepAlive from 'stack-keep-alive'
const app = Vue.createApp({})
app.use(StackKeepAlive)
...

Configuration

1. replace whitelist

When the tab bar is switched, some tab pages need to be retained, and these paths can be configured in replaceStay

<stack-keep-alive v-slot='{ key }' :replaceStay='["/foo"]'> 
    <component :is="Component" :key='key'/>
</stack-keep-alive>

2. transition

For use with transition, you need to replace the transition component with the built-in sk-transition component.Use name and back_name to achieve two different animation effects. Sameple Code here

    <router-view v-slot="{ Component }">
      <sk-transition name='slide-left' back_name='slide-right'>
        <stack-keep-alive v-slot="{ key }">
          <component :is="Component" :key='key'/>
        </stack-keep-alive>
      </sk-transition>
    </router-view>

3. singleton route

Sometimes it is expected that a component is only created once in the entire application life cycle, such as the common shopping cart page, in this case, use singleton to configure singleton route

<stack-keep-alive v-slot='{ key }' :singleton='["/foo"]'> 
    <component :is="Component" :key='key'/>
</stack-keep-alive>

Sample code

Sample code

Online demo

Animation