xanf/vuex-shared-mutations

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

xanf commented

I'll take a look on that in next 48h alongside with releasing new version

@xanf Did you ever get a chance to look into this? This plugin looks super handy for my Nuxt project however I would like to use it as a Nuxt.js Plugin as @folamy was attempting to. An example of how to use it in this way would be fantastic!

xanf commented