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

vuex-along

v1.2.13

Published

Automatically restore vuex state after refreshing the page

Downloads

302

Readme

English | 简体中文

Directory

Install

npm install vuex-along --save
# or
yarn add vuex-along

Usage

import createVuexAlong from 'vuex-along'

export default new Vuex.Store({
  state:{...},
  modules:{...},
  plugins: [createVuexAlong()]
});

Now, the plugin has been in effect, and all state is stored to localStorage by default.

Set Options to meet the usage requirements

Example

→ Online Example

import createVuexAlong from "vuex-along";

const moduleA = {
  state: {
    a1: "hello",
    a2: "world",
  },
};

const store = new Vuex.Store({
  state: {
    count: 0,
  },
  modules: {
    ma: moduleA,
  },
  plugins: [
    createVuexAlong({
      //Set the collection name to avoid multi-project data conflicts with the same site
      name: "hello-vuex-along",
      local: {
        list: ["ma"],
        // Filter the module ma data, save the other to localStorage
        isFilter: true,
      },
      session: {
        // Save a1 in module ma to sessionStorage
        list: ["ma.a1"],
      },
    }),
  ],
});

Options

VuexAlongOptions

| Field | Required | Type | Description | | ----------- | ------------ | -------- | ------------------------------------------------------------------------ | | name | no | String | Set the name of the local data collection, the default is vuex-along | | local | no | Object | LocalStorage configuration, see #WatchOptions | | session | no | Object | SessionStorage configuration, see #WatchOptions | | justSession | no | Boolean | Use only sessionStorage |

WatchOptions

| Field | Required | Type | Description | | --------- | ------------ | --------- | ------------------------------------------------------------------------------ | | list | yes | String [] | List of strings of attribute names or module names that need to be listened to | | isFilter | no | Boolean | Filter fields in list instead of saving |

Cleanup

window.clearVuexAlong(local = true, session = true):void;
clearVuexAlong() // localStorage and sessionStorage will be cleaned up
clearVuexAlong(true,false) // Just localStorage
clearVuexAlong(false,true) // Just sessionStorage

RunDemo

git clone https://github.com/boenfu/vuex-along.git
cd ./vuex-along
yarn run:demo

Tips

  • Support typescript
  • Support IE11
  • sessionStorage data recovery takes precedence over localStorage
  • The key of the top-level object that stores the content is fixed to root

Contribution

Maintainers

License