Skip to content

Allow bindActionCreators to be used with function as actionCreator #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2015
Merged

Allow bindActionCreators to be used with function as actionCreator #352

merged 1 commit into from
Jul 29, 2015

Conversation

michaelcontento
Copy link
Contributor

With this change you can use bindActionCreators to either bind a object of actionCreator functions to dispatch or only a single actionCreator directly.

import { bindActionCreators } from 'redux';
import { addTodo } from './actions/todoActions';

const boundAddTodo = bindActionCreators(addTodo, dispatch);
boundAddTodo('Hello');

@@ -1,13 +1,18 @@
import mapValues from '../utils/mapValues';

function bindActionCreator(actionCreator, dispatch) {
return (...args) => dispatch(actionCreator(...args));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be two spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry! Maybe a .editorconfig file would be nice? This way most editors will recognize the proper indent / lineending style :)

@gaearon
Copy link
Contributor

gaearon commented Jul 29, 2015

Please squash in a single commit?

With this change you can use `bindActionCreators` to either bind a
object of actionCreator functions to dispatch or only a single
actionCreator directly.

    import { bindActionCreators } from 'redux';
    import { addTodo } from './actions/todoActions';

    const boundAddTodo = bindActionCreators(addTodo, dispatch);
    boundAddTodo('Hello');
@michaelcontento
Copy link
Contributor Author

Done :)

gaearon added a commit that referenced this pull request Jul 29, 2015
…dActionCreators

Allow `bindActionCreators` to be used with function as actionCreator
@gaearon gaearon merged commit 3cfdd73 into reduxjs:breaking-changes-1.0 Jul 29, 2015
@gaearon
Copy link
Contributor

gaearon commented Jul 29, 2015

Awesome, thanks!

@michaelcontento michaelcontento deleted the function-support-for-bindActionCreators branch August 14, 2015 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants