Questions tagged [vuex-modules]

Use this tag for Vuex questions in which the store is subdivided into Vuex modules.

As a Vuex application grows in scale, the store and state tree can get increasingly bloated.

To help with that, Vuex allows us to divide our store into modules. Each module can contain its own state, mutations, actions, getters, and even nested modules.

By default, actions, mutations and getters inside modules are still registered under the global namespace - this allows multiple modules to react to the same mutation/action type.

Read more in the Modules section of Vuex's official website

327 questions
4
votes
3 answers

How to elegantly use v-model and Vuex store?

I search for a clean way to use v-model and vuex store. Vuex provide several helpers methods are pretty usefull but a little bit annoying when using with v-model. The way I do today to use v-model and my modularized store is like computed: { type:…
Daividh
  • 395
  • 1
  • 4
  • 11
4
votes
3 answers

Breaking Vuex actions into multiple files

I'm already using modules to break down my Vuex stores into separate files but an wonder if and how you could break a stores actions into multiple files again? Some context - I have a Products store in a Vue based Electron application. In this I…
Jam3sn
  • 1,077
  • 4
  • 17
  • 35
4
votes
1 answer

Accessing vuex module state from another module

I'm learning vuex and making some headway but I'm stuck on something. I have a vue component with a store containing a number of modules. I have locations with have equipment. User selects a location and I store that in in my vuex state in the…
Dylan Glockler
  • 1,115
  • 1
  • 20
  • 40
4
votes
1 answer

Listen to actions/mutations from within a vuex modules

I have a vuex store with several modules, and I want to be able to listen to "global" dispatch or commit calls (aka actions and mutations) from within a module. For example, in an auth module there are actions like login and logout. Whenever those…
Wessel van der Linden
  • 2,592
  • 2
  • 21
  • 42
4
votes
1 answer

How to use Vue plugin in Store?

Is there a proper / documented way of using a plugin inside vuex module or plain js module? I am using event bus to acheive it, not sure if it is the correct / best way. Please help. Plugin1.plugin.js: const Plugin1 = { install(Vue, options) { …
JVM
  • 946
  • 1
  • 10
  • 23
4
votes
1 answer

Vuex inside nuxt app throws "Do not mutate vuex store state outside mutation handlers"!

In my NUXT app I am using vuex store modules! When I run the app and call this.$store.dispatch('userStore/setLoggedInUser',currentUser); //default.vue I get an error saying "Do not mutate vuex store state outside mutation handlers" that loops…
Jørgen Andersen
  • 641
  • 9
  • 19
4
votes
2 answers

Nuxt, splitting up Vuex store into separate files gives error: unknown mutation type: login

I'm trying to split up my Nuxt Vuex store files into separate files. And NOT have all Vuex getters, mutations and actions into one huge file. This demo project is on Github by the way. I'v read this official Nuxt Vuex Store documentation; but can't…
Dennis Burger
  • 259
  • 4
  • 13
3
votes
4 answers

Cannot read properties of undefined (reading 'getters')

Can anyone help with the below, I am getting the following error Cannot read properties of undefined (reading 'getters') I am working on a project where my stores should return an array to my index.vue Is there also any way I can get around this…
3
votes
1 answer

Order of Execution for VueJS dispatch function is causing an issue

I'm trying to display a list of announcements (retrieved from API) on the page. I'm using Vuex store and I have a state called announcements. I also want this list to be updated every time the user refreshes/enters the page. So I used lifecycle…
3
votes
2 answers

How we can access to Vuex store instance inside store module file in vuex-module-decorators + Nuxt TypeScript?

There are many possible ways to construct your modules. vuex-module-decorators official readme One of the most popular approaches is vuex-module-decorators. Nuxt TypeScript official documentation Well, where at least two approaches has been…
3
votes
3 answers

VueX wait for mutation to execute

Is it possible in VueX to make a method in mounted() wait until some mutation in other component is executed? Because sometimes that mutation is executed before and sometimes after so therefore I would know if it would be possible to await after it…
Alex T
  • 3,529
  • 12
  • 56
  • 105
3
votes
0 answers

Cannot access vuex mutation in dynamically registered module

I have created a module to grab api data and hold it for a vue component: import Vue from 'vue'; export default { namespaced: true, state() { return { all: [] } }, getters: { all(state) { …
joshua jackson
  • 629
  • 1
  • 6
  • 17
3
votes
0 answers

How can I dynamically register and deregister vuex-module-decorators stores?

I have a vuex-module-decorators decorated Vuex store. I want to be able to dynamically load and unload the module depending on which Vue component I am in, so that I don't have all stores loaded at the same time (only the ones in use). @Module({ …
Birdie
  • 274
  • 2
  • 14
3
votes
2 answers

How to access other Vuex modules with typescript?

I'm trying to write a Vuex store with typescript (not using vuex-module-decorators, just plain Vuex + typescript to keep things simple). My root store has no state, just modules: export interface RootState { } export const store:…
GaryO
  • 5,873
  • 1
  • 36
  • 61
3
votes
1 answer

TypeScript Error in Vuex Module - Something wrong that sub-module is unable to assign into index Module of Vuex

I'm building a simple vue-project using TypeScript. I wrote the vuex store in my vue project, and the store has a sub-module called 'calculation'. But once created the main store including sub-module, a weird error (tserror) occurs. Following is my…
JesssssL
  • 31
  • 1
  • 5
1 2
3
21 22