Skip to content

Mixin for integrate action creators in methods of vue component

Notifications You must be signed in to change notification settings

kolesoffac/redux-store-mixin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-store-mixin

NPM

npm version npm downloads

Mixin for integrate action creators in methods of vue component

Install

npm install --save redux-store-mixin

Usage

1. Import mixin

import reduxStoreMixin from "redux-store-mixin";

2. Import our actionCreators

import {actionCreators} from "store/store";

3. Import mapState-method for useful connect with props from redux-store

import { mapState } from "vuex";

4. Create vue instance

new Vue({
  mixins: [
                ...
		reduxStoreMixin(actionCreators),
                ...
  ],
  computed: {
		...mapState({
			prop1: state => state.redux.map.prop1,
	      		...
	      		propN: state => state.redux.map.propN
	    	}),
	    	...
  },
  ...
});

Example

Call action:

...
methods: {
  someMethod: function () {
    this.reduxActions("actionName", [...argsForAction]);
  }
},
...

For more information see

About

Mixin for integrate action creators in methods of vue component

Resources

Stars

Watchers

Forks

Packages

No packages published