pinia-shared-state
v1.0.1
Published
[](https://www.npmjs.com/package/pinia-shared-state) ,
)const useStore = defineStore({
id: 'counter',
state: () => ({
count: 0,
foo: 'bar',
}),
share: {
// An array of fields that the plugin will ignore.
omit: ['foo'],
// Override global config for this store.
enable: true,
initialize: true,
},
})Vanilla usage:
import { share } from 'pinia-shared-state'
import { onMounted, onUnmounted } from 'vue'
import useStore from './store'
const counterStore = useStore()
onMounted(() => {
const { unshare } = share('counter', counterStore, { initialize: true })
onUnmounted(() => {
// Call `unshare` method to close the channel
unshare()
})
})License
MIT
