UNPKG

@stfalcon/vuex-crud-module-creator

Version:
30 lines (27 loc) 711 B
const mapGettersByProperty = (namespace, fields) => { return fields.reduce((acc, current) => { const field = { get() { const getterPath = `${this[namespace]}/${current}`; return this.$store.getters[getterPath]; }, }; return { ...acc, [current]: field, }; }, {}); }; const mapActionsByProperty = (namespace, actions) => { return actions.reduce((acc, current) => { const action = function(payload) { const actionPath = `${this[namespace]}/${current}`; return this.$store.dispatch.call(this, actionPath, payload); }; return { ...acc, [current]: action }; }, {}); }; export { mapGettersByProperty, mapActionsByProperty }