vue-redux-prepare-props

0.0.7 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i vue-redux-prepare-props

Weekly Downloads

0

Version

0.0.7

License

Apache-2.0

Unpacked Size

22.2 kB

Total Files

14

Last publish

Collaborators

  • kolesoffac