The motivation of encapsulating more of the Vuex functionality is to extend the type-safety to more parts of Vuex.
Root Vuex Module
The first step would be to encapsulate the creation of the root Vuex module, then we can also pass pre-made proxies to actions and getters.
To do this we are missing options for plugins, strict, and devtools.
Class decorator
import { VuexClass } from 'vuex-class-component'
@Store({
strict: boolean,
devtools: boolean,
plugins: Plugin<Store>[]
})
class Store extends VuexClass {
}
Constructor options
import { VuexClass } from 'vuex-class-component'
class Store extends VuexClass {
constructor() {
super({
strict: boolean,
devtools: boolean,
plugins: Plugin<Store>[]
})
}
}
Configuring sub-modules
import { VuexClass } from 'vuex-class-component'
class Store extends VuexClass {
auth = new AuthModule()
}
class AuthModule extends Store.SubModule(store => store.auth) {
}
Other possibilities
We could implement decorators for Watch, Subscribe, and SubscribeAction. This way we could have actions or mutations be called as reactions to other parts of the state without the origin knowing what methods to call after a change. I.e. Fetch different kinds data after login state changed/login action is called/login mutation is called without them knowing what actions or mutations that relies on it.
The motivation of encapsulating more of the Vuex functionality is to extend the type-safety to more parts of Vuex.
Root Vuex Module
The first step would be to encapsulate the creation of the root Vuex module, then we can also pass pre-made proxies to actions and getters. To do this we are missing options for
plugins
,strict
, anddevtools
.Class decorator
Constructor options
Configuring sub-modules
Other possibilities
We could implement decorators for
Watch
,Subscribe
, andSubscribeAction
. This way we could have actions or mutations be called as reactions to other parts of the state without the origin knowing what methods to call after a change. I.e. Fetch different kinds data after login state changed/login action is called/login mutation is called without them knowing what actions or mutations that relies on it.