1.0.4 • Published 6 years ago

vuex-persisted-tool v1.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

vuex-persisted-tool

Persist Vuex state with localStorage or other storages.

Installation

$ npm install vuex-persisted-tool --save

Usage

import createPersistedState from 'vuex-persisted-tool'

const store = new Vuex.Store({
  // ...
  plugins: [createPersistedState()]
})

Customize Storage

import { Store } from 'vuex'
import createPersistedState from 'vuex-persisted-tool'
import * as Cookies from 'js-cookie'

const store = new Store({
  // ...
  plugins: [
    createPersistedState({
      storage: {
        getItem: key => Cookies.get(key),
        // Please see https://github.com/js-cookie/js-cookie#json, on how to handle JSON.
        setItem: (key, value) => Cookies.set(key, value, { expires: 3, secure: true }),
        removeItem: key => Cookies.remove(key)
      },
      // ignore some states
      ignore: ['someinfo', 'userinfo'],
    })
  ]
})

License

MIT

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago