Skip to content

Helper for use props of Redux with Vue.js using Vuex and Vuedeux

License

Notifications You must be signed in to change notification settings

kolesoffac/vue-redux-prepare-props

Repository files navigation

Vue-redux-prepare-props

NPM

npm version npm downloads

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

  1. Created computed props from selectors with prefix(default: "inner_");
  2. Created initial values from props using selectors;
  3. 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),
        ...
    };
  },
  ...
};

License

Apache-2.0

About

Helper for use props of Redux with Vue.js using Vuex and Vuedeux

Resources

License

Stars

Watchers

Forks

Packages

No packages published