Skip to content

Instantly share code, notes, and snippets.

@rougeth
Last active January 23, 2017 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rougeth/f18b25a8036e026bcbe649b66c4eab4a to your computer and use it in GitHub Desktop.
Save rougeth/f18b25a8036e026bcbe649b66c4eab4a to your computer and use it in GitHub Desktop.
import {connect} from 'react-redux';
function connector(mapStateToProps, mapDispatchToProps, composes, component) {
const conn = connect(mapStateToProps, mapDispatchToProps);
return conn(composes.reduce((a, b) => b(a(component))));
}
@renanvalentin
Copy link

renanvalentin commented Jan 23, 2017

I would suggest to change to something more declarative. Like a reduce instead of a for..of loop. Plus I don't think we should wrapp the connect method, rather we could enhance the component

connect(mapState, mapDispatch)(enhance(Component, [1..n]));

or using decorators.

What about those scenarios that we pass a second argument?
Compose([1..n], doSomething())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment