@tonyptang/store-helper
v1.7.0
Published
```ts // npm i @tonyptang/store-helper // for vuex import { useMapState } from '@tonyptang/store-helper/vuex' const { state } = useMapState('moduleName', ['state'])
Downloads
4
Readme
// npm i @tonyptang/store-helper
// for vuex
import { useMapState } from '@tonyptang/store-helper/vuex'
const { state } = useMapState('moduleName', ['state'])
const { state } = useMapState('moduleName', ['state'], true)
state.value = 'changed'
// for pinia
import { useStoreToRefs } from '@tonyptang/store-helper/pinia'
const store = defineStore('id', () => {
const count = ref(0)
const increment = () => count.value++
return {
count,
increment
}
})
export const countStore = () => useStoreToRefs(store)
// usage
const { count, increment } = countStore()
console.log(count.value) // 0