Closed jmotes closed 5 years ago
Hi @jmotes ,
As I don't know exactly what you have in the module I will just propose different solutions you could use for now:
class CounterState {
@State()
public counter: number = 10;
}
class CounterGetters extends CounterState { @Getter() public get counterPlusHundred() { return this.counter + 100; } }
class CounterMutations extends CounterGetters { @Mutation() public increment() { this.counter++; } }
class CounterActions extends CounterMutations { public async incrementAsync() { await new Promise(r => setTimeout(r, 500)); this.increment(); } }
@Module('counter') class CounterModule extends CounterActions {}
What do you think about the last solution? Though it isn't perfect and probably also isn't the best way to handle this problem, it should enable us to split the module into separate parts.
Don't hesitate to tell me if you have other better ideas!
Hi @jmotes,
1.2.0 is now out with #10 and includes as said inheritance in the same way as presented above. Hope it solves your problems.
Sascha
Thanks @sascha245!
I'm submitting a ... [ ] bug report [ ] feature request [ ] question about the decisions made in the repository [X ] question about how to use this project
Summary I have a rather large module that I'm currently splitting into separate classes - state, mutations, getters, and actions - and then bringing them together as a Vuex
Module
object for readability purposes. Do you have any recommendations for doing the same with vuex-simple? I was reading up on Typescript partial types, but not 100% sure if that's the best route.Thanks!