vue-redux-prepare-props
v0.0.7
Published
Helper for use props of Redux with Vue.js using Vuex and Vuedeux
Downloads
8
Readme
Vue-redux-prepare-props
Helper for use props of Redux with Vue.js using Vuex and Vuedeux
Resolved problem
When change only one prop from redux state then triggering all computed and wathers where using props of redux state, which did not change, because always change root object. It's sensitive when prop is object or array.
How it works
- Created computed props from selectors with prefix(default: "inner_");
- Created initial values from props using selectors;
- Created watchers for "inner_" props and when object mutated from selectors then set prop this value.
Using
import { mapState } from "vuex";
import prepareProps from "vue-redux-prepare-props";
const props = {
prop1: state => state.redux.prop1,
...
propN: state => state.redux.propN
};
const {calcs, datas, watchers} = prepareProps(props);
export default {
computed: {
//redux store
...mapState(calcs),
...
},
watch: {
...watchers,
...
},
data () {
return {
...datas(this),
...
};
},
...
};