Split Vuex Store into Modules using TypeScript

Share this video with your friends

Send Tweet

When the Vuex store grows, it can have many mutations, actions and getters, belonging to different contexts. Vuex allows you to split your store into different contexts by using modules.

In this lesson we’ll see how can we split the store in multiple Vuex modules using TypeScript

Brad Tittle
Brad Tittle
~ 7 years ago

This may or may not help.

I used the mutation-types method to create my mutations in modules. The mutations were not triggering when I called them from my component.

this.$store.commit(types.ADD_ITEM, item) wasn't working.

I found the problem when I console.log(types) right after the import of types.

The console.log didn't fix the problem. It might have pointed to the fact that I hadn't saved my mutation-types.js file. It was saved, but it wasn't saved... ...

Calle Hunefalk
Calle Hunefalk
~ 6 years ago

I get this tslint warning in VSCode with the example code from login.ts from the Github repo: [tslint] Shadowed name: 'state' [no-shadowed-variable]