How to implement this vuex-shared-mutations with nuxtjs
folamy opened this issue · 6 comments
Please How can i used vuex-shared-mutations with nuxtjs
my code looks like
`//plugin/sharedmutations.js
import createMutationsSharer from 'vuex-shared-mutations';
import Vuex from 'vuex'
const store = new Vuex.Store({
// ...
plugins: [
createMutationsSharer({
predicate: (mutation, state) => {
const predicate = ['addTocart', 'qtyInc', 'qtyDec', 'qtyReset']
return predicate.indexOf(mutation.type) >= 0;
},
}),
],
});
//nuxt-config.js
//plugins
plugins: [
'@/plugins/sharedMutation',
],
`
my code looks like
`//plugin/sharedmutations.js
import createMutationsSharer from 'vuex-shared-mutations';
import Vuex from 'vuex'const store = new Vuex.Store({
// ...
plugins: [
createMutationsSharer({
predicate: (mutation, state) => {
const predicate = ['addTocart', 'qtyInc', 'qtyDec', 'qtyReset']
return predicate.indexOf(mutation.type) >= 0;
},
}),
],
});//nuxt-config.js
//plugins
plugins: [
'@/plugins/sharedMutation',
],`
can it work?I know a vuex-persistedstate that it work in nuxt like:
`
// nuxt.config.js
...
plugins: [{ src: '~/plugins/localStorage.js', ssr: false }]
...
// ~/plugins/localStorage.js
import createPersistedState from 'vuex-persistedstate'
export default ({store}) => {
window.onNuxtReady(() => {
createPersistedState({
key: 'yourkey',
paths: [...]
...
})(store)
})
}
`
But I don't know how to implement this one
I'll take a look on that in next 48h alongside with releasing new version
@wSedlacek
https://github.com/xanf/vuex-shared-mutations/tree/master/examples/nuxt
See v1.0.2 of this plugin