-
-
Save uno-de-piera/b9fea2b7d2eafb3a6c42ad9d01f8dcfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import store from './store'; | |
export function computedPropertiesGenerator (props = [], {pathStore, mutation} = {}) { | |
return props.reduce((obj, prop) => { | |
obj[prop.property] = { | |
get() { | |
return store.state[pathStore][prop.property] || prop.defaultValue; | |
}, | |
set(value) { | |
store.commit(mutation, { | |
property: prop.property, | |
value | |
}) | |
} | |
} | |
return obj | |
}, {}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment