Skip to content

grandchef/vuex-persistedstate-migrate

Repository files navigation

TypeScript version Node.js version MIT

Vuex Persistedstate Migrate

Library to migrate vuex state using vuex-persistedstate. See on npm

Install

Run command bellow on your project folder

yarn add vuex-persistedstate-migrate

or

npm install vuex-persistedstate-migrate

Example

import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import createMigrate from 'vuex-persistedstate-migrate'

const migrations = [
  {
    version: 1,
    up: state => {
      return {
        ...state,
        myModule: {
          ...state.myModule,
          myProperty: 'migrated value',
        }
      }
    }
  }
]

Vue.use(Vuex)

const store = new Vuex.Store({
  plugins: [createPersistedState({
    getState: createMigrate(migrations, 'migration.version'),
  })],
  modules
})

export default store

Available scripts

  • clean - remove coverage data, Jest cache and transpiled files,
  • build - transpile TypeScript to ES6,
  • build:watch - interactive watch mode to automatically transpile source files,
  • lint - lint source files and tests,
  • style:fix - fix prettier style problems,
  • style:check - check for prettier style,
  • test - run tests,
  • test:watch - interactive watch mode to automatically re-run tests
  • test:debug - run tests debugging

License

Licensed under the MIT. See the LICENSE file for details.