Redux: Feature request: autocurry bindActionCreators

Created on 22 Feb 2017  ·  3Comments  ·  Source: reduxjs/redux

A common use case for bindActionCreators (at least with React) is as follows:

const mapDispatchToProps = (dispatch) => bindActionCreators({
    myActionCreator,
    anotherActionCreator
}, dispatch);

If the function were auto-curried (can be called with two arguments, but will return a function if called with only one argument) that could be simplified to:

const mapDispatchToProps = bindActionCreators({
    myActionCreator,
    anotherActionCreator
});

Pros

  • Simpler call syntax.
  • Intuitive behavior for those familiar with currying.

Cons

  • Somewhat "magical" ("Where does dispatch come from??!!")
  • Multiple ways to write the same thing.
  • Possibly difficult/confusing to document.
  • Unintuitive/confusing for those not familiar with currying.

If this is something worth exploring, I'd be happy to open a pull request so we can see what an actual implementation would look like.

All 3 comments

Yeah, let's do a PR and discuss this with some real code behind it.

Given that we already have the object shorthand for connect, I'm not sure I see the exact use case here.

@markerikson Good point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olalonde picture olalonde  ·  3Comments

vraa picture vraa  ·  3Comments

jbri7357 picture jbri7357  ·  3Comments

vslinko picture vslinko  ·  3Comments

rui-ktei picture rui-ktei  ·  3Comments