npm.io
1.1.0 • Published 5 years ago

@naturalcycles/vue-lib

Licence
MIT
Version
1.1.0
Deps
1
Size
13 kB
Vulns
0
Weekly
0

@naturalcycles/vue-lib

Useful functions for Vue.js 2.x

npm min.gz size code style: prettier

Features

createLocalStoragePlugin

LocalStorage persistence plugin for Vuex 3.x (compatible with Vue 2.x).

Works in Nuxt (!).

interface GlobalState {
  count: number
}

const emptyState: GlobalState = {
  count: 0,
}

export const localStoragePlugin = createLocalStoragePlugin<GlobalState>({
  emptyState,
})

export const store = new Vuex.Store<GlobalState>({
  mutations: {},
  plugins: [localStoragePlugin],
})