Skip to content
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

Feature request: autocurry bindActionCreators #2259

Closed
captbaritone opened this issue Feb 22, 2017 · 3 comments
Closed

Feature request: autocurry bindActionCreators #2259

captbaritone opened this issue Feb 22, 2017 · 3 comments

Comments

@captbaritone
Copy link
Contributor

captbaritone commented Feb 22, 2017

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.

@timdorr
Copy link
Member

timdorr commented Feb 22, 2017

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

@markerikson
Copy link
Contributor

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

@captbaritone
Copy link
Contributor Author

@markerikson Good point.

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

No branches or pull requests

3 participants