I spent a lot of time figuring out how to use vuex map helper function and finally, I didn't figure it out.
Now I have something like this:
setup (_, { root: { $store } }) {
onMounted(() => {
$store.commit('app/setApplicationWidth', innerWidth)
console.log($store.getters['app/getApplicationWidth'])
})
}
So how I can use mapGetters, and mapMutations in composition API?
My vuex store looks like this: /store/app.ts
import { GetterTree, MutationTree, ActionTree } from 'vuex'
export const state = () => ({
appWidth: <Number> 0
})
export type RootState = ReturnType<typeof state>
export const mutations: MutationTree<RootState> = {
setApplicationWidth (state: any, payload: Number) {
state.appWidth = payload
}
}
export const getters: GetterTree<RootState, RootState> = {
getApplicationWidth (state: any): Number {
return state.appWidth
}
}
export const actions: ActionTree<RootState, RootState> = {}