0.6.1 • Published 2 years ago

vuex-persistent-plugin v0.6.1

Weekly downloads
60
License
-
Repository
-
Last release
2 years ago

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.
});
0.6.1

2 years ago

0.6.0

2 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.6

4 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago