B
B
BonBon Slick2021-12-16 02:58:07
Vue.js
BonBon Slick, 2021-12-16 02:58:07

How to save dynamic store module (state, action, getter, mutation) manually?

https://github.com/gertqin/vuex-class-modules/issues/72

Here is a package, it solves the problems that I had in a large monolith with a large store, namely
1 - reusability (inheritance and extension, functionality is difficult to debug )
2 - reduction of the boiler plate (use of vuex-class and all its ensuing inability to create a dynamic mixin, which forces you to declare dozens of getters and actions for each template)
3 - improved support (readability, strong typing, easier to debug)
4 - dynamic modules, can be attributed to point 3, when you have 50+ modules in the repository and you open the debug bar, it will take years until you find the desired state and its getter + the security can suffer in theory. Admin modules will be initialized only on the admin page.
5 - purer mutations, now they exclusively mutate the state and do not perform additional functions such as deep search where and what data to mutate, everything happens in the action, the getter is called there, the data is found, a new object is collected, the mutator is called to replace.

of the most noticeable minuses
1 - you can no longer merge several modules into one, lack of multi-inheritance

export default () => _.merge({}, module_1, module_2, module_3, module_4....}) ;

But the modules exist only when the site is opened for the first time, after the page is reloaded, the actions / getters disappear, and the state is reset.

I do not understand how to fix and how much time it will take time.
There are relevant issues
https://github.com/gertqin/vuex-class-modules/issues/60
https://github.com/gertqin/vuex-class-modules/issues/24
https://github.com/gertqin /vuex-class-modules/issues/31
https://github.com/gertqin/vuex-class-modules/issues/36

In theory, you need to add something of your own to save the state, for example, in "vuex-persistedstate": "^3.2.0",

Who has faced such a manul persistence?
Please tell me how did you decide?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question