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: pass this through bound actionCreator #2638

Closed
Parakleta opened this issue Oct 3, 2017 · 4 comments
Closed

Feature Request: pass this through bound actionCreator #2638

Parakleta opened this issue Oct 3, 2017 · 4 comments

Comments

@Parakleta
Copy link
Contributor

Is there any chance of changing bindActionCreator from:

function bindActionCreator(actionCreator, dispatch) {
  return (...args) => dispatch(actionCreator(...args))
}

to:

function bindActionCreator(actionCreator, dispatch) {
  return function() { return dispatch(actionCreator.apply(this, arguments)); };
}

The existing behaviour explicitly sets this to undefined so this shouldn't be a breaking change.

I have some mixins/decorators that I apply to action creators by composition such that the arguments don't change but I can adjust settings in the enhancer by passing an object through this. If I use some of the convenience functions like connect I lose the ability to pass through these objects.

@timdorr
Copy link
Member

timdorr commented Oct 3, 2017

Can you put this together as a PR with some tests to go along with it?

@markerikson
Copy link
Contributor

I'd also like to see some examples of the actual use case for the behavior. I'm not sure if passing through this is something we really want to encourage.

@Parakleta
Copy link
Contributor Author

I’m sure it isn’t something you want to encourage, but then is it the place of redux to police code quality or rather should it provide a shining example of what can be achieved and then get out of the way. As troubled as it is and as often as it blows up for people, this is a valid part of the call mechanism in javascript and redux shouldn’t just swallow it.

@Parakleta
Copy link
Contributor Author

Parakleta commented Oct 3, 2017

@timdorr I haven’t any experience with your testing framework, but I’ll see if I can find some time tomorrow to set it up. Sans tests the PR is one line.

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