Last active
January 23, 2017 17:42
-
-
Save rougeth/f18b25a8036e026bcbe649b66c4eab4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would suggest to change to something more declarative. Like a
reduce
instead of afor..of
loop. Plus I don't think we should wrapp the connect method, rather we could enhance the componentconnect(mapState, mapDispatch)(enhance(Component, [1..n]));
or using decorators.
What about those scenarios that we pass a second argument?
Compose([1..n], doSomething())