Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,17 @@ function mapActionToProps(dispatch) {
data: { todo }
})
}
}
};
}

function mergeProps(stateProps, actionsProps) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you write another block of documentation for mergeProps rather than putting it in the here? some users will think its a required parameter :)

return {
...stateProps,
...actionsProps,
};
}

export default connect(mapStateToProps, mapActionToProps)(App);
export default connect(mapStateToProps, mapActionToProps, mergeProps)(App);

```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-vue",
"version": "0.7.1",
"version": "0.8.1",
"description": "Vue Redux binding higher order component",
"author": "Nadim Tuhin",
"repository": {
Expand Down
14 changes: 11 additions & 3 deletions src/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ function getProps(component) {
};
}

function defaultMergeProps(stateProps, actionsProps) {
return {
...stateProps,
...actionsProps,
};
}

/**
* 1. utilities are moved above because vue stores methods, states and props
* in the same namespace
Expand All @@ -53,11 +60,13 @@ function getProps(component) {
/**
* @param mapStateToProps
* @param mapActionsToProps
* @param mergeProps
* @returns Object
*/
export default function connect(mapStateToProps, mapActionsToProps) {
export default function connect(mapStateToProps, mapActionsToProps, mergeProps) {
mapStateToProps = mapStateToProps || noop;
mapActionsToProps = mapActionsToProps || noop;
mergeProps = mergeProps || defaultMergeProps;

return (children) => {

Expand Down Expand Up @@ -90,8 +99,7 @@ export default function connect(mapStateToProps, mapActionsToProps) {
const actionNames = Object.keys(actions);

return {
...state,
...actions,
...mergeProps(state, actions),
vuaReduxStateNames: stateNames,
vuaReduxActionNames: actionNames
};
Expand Down