Vuex module with multiple states


#1

I need to be able to store a series of state objects and have the actions, mutations and getters to be applied to a specific one each time.
The idea is to create an undo plugin (based on actions) so I need to have 1-2 snapshots of the current state and to be able to execute actions on the snaphsots (not on the current state - I need the current state intact since it is used reactively).
However, not being experienced in JS, I cannot see how I could implement this.
The obvious way would be to create 2 different modules, put the actions, mutations and getters into separate files and import these files into these two modules and also have them sync their state objects when necessary.
But if later I needed 2 state snapshots, I would then need to create another module e.t.c.
I know my state object could also be a function, but I could not come up with a solution that would make the dispatch() calls to choose a specific state.
I would be grateful if you guys could shed some insight here!
Panayotis


#2

Maybe Vuex modules its what you need.

https://vuex.vuejs.org/guide/modules.html