schepotin-vuex-helpers
v0.0.8
Published
Helpers for vuex
Downloads
2
Readme
Vuex helpers
mapTwoWayState
Generates two way computed properties.
...mapTwoWayState({
namespace: 'user',
prefix: true,
}, [
'name',
]),
generates:
userName: {
get() {
return this.$store.getters['user/name'];
},
set(value) {
this.$store.commit(`user/NAME`, value);
},
},
mapGettersFromStates
...mapGettersFromStates({
states,
}),
generates:
{
id: state => state.id,
name: state => state.name,
mail: state => state.email,
}
mapMutationsFromTypes
Generates mutations from mutation types
...mapMutationsFromTypes({
types,
}),
generates:
{
[types.ID](state, payload) {
state.id = payload;
},
[types.NAME](state, payload) {
state.name = payload;
},
[types.EMAIL](state, payload) {
state.email = payload;
},
}