Example using vuex modules
See original GitHub issueI’ve used Vuex before but never in this module sense. I am purely trying to use the vuex Counter that this package ships with. I’ve tried the following to no resolve any help would be nice. /src/renderer/store/modules/Counter.js
const state = {
main: 0
}
const mutations = {
DECREMENT_MAIN_COUNTER (state) {
state.main--
},
INCREMENT_MAIN_COUNTER (state) {
state.main++
}
}
const actions = {
someAsyncTask ({ commit }) {
// do something async
commit('INCREMENT_MAIN_COUNTER')
}
}
export default {
state,
mutations,
actions
}
/src/renderer/views/Welcome.vue
<template lang="pug">
button(@click="test")
</template>
<script>
export default {
name: 'Welcome',
data () {
return {
}
},
methods: {
test () {
// what I expect to work
this.$store.dispatch('someAsyncTask')
// what I expected with "modules"
this.$store.dispatch('Counter.someAsyncTask')
// another attempt
this.$store.Counter.dispatch('someAsyncTask')
}
}
}
</script>
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Modules
To help with that, Vuex allows us to divide our store into modules. Each module can contain its own state, mutations, actions, getters, ......
Read more >Vuex Modules - A Vue.js Lesson From our Vue.js Course
Each Vuex modules can contain its own state, mutations, actions, getters and even their own modules. In this vue.js tutorial, we'll learn how...
Read more >Vuex modules example
Vuex modules example. 1. Embed Fork Create Sandbox Sign in. Sandbox Info. Vuex modules example. 1. 1.5k. 33. nemoipahanemoipaha. Environmentvue-cli. Files.
Read more >Managing multiple store modules with Vuex
Vuex modules are essentially small, independent Vuex stores that are combined into a larger, central Vuex store. This makes managing them much ...
Read more >Vuex Modules Tutorial, how to scale your Store
Vuex Modules are simply Vuex stores inside other Vuex stores. Don't worry, it is much simpler than it sounds. In our previous tutorial,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@StringKe @grrowley Resolved by disable this :
import { createNamespacedHelpers } from 'vuex'