Socket
Socket
Sign inDemoInstall

vuex-persistent-plugin

Package Overview
Dependencies
4
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vuex-persistent-plugin

This is a plugin for Vuex that uses PouchDB to store data on the client. A helper library is provided to make working with PouchDB a little easier with more 1-liners.


Version published
Maintainers
1
Install size
15.0 MB
Created

Readme

Source

Vuex Persistent Plugin

This is a plugin for Vuex that uses PouchDB to store data on the client. A helper library is provided to make working with PouchDB a little easier with more 1-liners.

Installation
npm install --save vuex-persistent-plugin

Basic Usage

import Vue from 'vue';
import Vuex from 'vuex';
import persistent from 'vuex-persistent-plugin/src/persistent';

Vue.use(Vuex);

const defaultState = {
    config: {}
};

export default new Vuex.Store({

    state: Object.assign({}, defaultState),

    plugins: [
        persistent({
            // options
        })
    ]

});

Config

Config's are key/value pairs. This a helper method to return the config data from the stored doc.

import { config } from 'vuex-persistent-plugin/src/Storage';

config('key', true);

config('key').then(docs => {
    console.log(docs) // true
});

Cache

Cache's extend the config methods, but track when the values should be purged. Config values are saved forever, cache values can expire.

import { cache } from 'vuex-persistent-plugin/src/Storage';

// Cache "key" for 10 seconds.
cache('key', () => Promise.resolve(true), 10).then(data => {
    console.log(data) // true
});

purge('key').then(docs => {
    console.log(docs) // array of docs that were removed.
});

FAQs

Last updated on 14 Dec 2021

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