vuex-class-persist
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-beta.2 • Public • Published

vuex-class-persist

Note: this project is a wrapper around Vuex-Persist and is not intended to steal any of ChampionSwimmer's code.

Link to Vuex-Persist

Features

  • All features found in Vuex-Persist
  • Ability to persist instances of classes in localStorage

Usage

The usage and creation is all the same as vuex-persist, except you also pass along an array of your classes so vuex-class-persist knows which classes to restore back to after the state has been reloaded from storage.

Steps

Import it

import VuexClassPersistence from 'vuex-class-persist'

Create an object

// You will need to be able to supply an array of your classes
// to ensure they get restored from storage.
const classes = [
  class User { /* Omitted */ },
  class Profile { /* Omitted */ },
  class Example { /* Omitted */ },
  ...
]

const vuexLocal = new VuexClassPersistence({
    storage: window.localStorage
}, classes)

Use it as Vue plugin. (in typescript)

const store = new Vuex.Store<State>({
  state: { ... },
  mutations: { ... },
  actions: { ... },
  plugins: [vuexLocal.plugin]
})

(or in Javascript)

const store = {
  state: { ... },
  mutations: { ... },
  actions: { ... },
  plugins: [vuexLocal.plugin]
}

Readme

Keywords

none

Package Sidebar

Install

npm i vuex-class-persist

Weekly Downloads

0

Version

0.0.1-beta.2

License

ISC

Unpacked Size

8.69 kB

Total Files

6

Last publish

Collaborators

  • coltenp