redux-rex
v0.1.0-alpha-9
Published
A microframework to write reusable components based on Redux.
Downloads
24
Readme
Rex
A microframework to write reusable components based on Redux.
Usage
import { run } from 'redux-rex';
const namespace = 'Shop/Overview';
const initialState = {
counter: 0
};
const action = (actions, { dispatch, getState }) => ({
*incrementAsync(milliseconds) {
setTimeout(() => {
dispatch(actions.openDialog());
yield put(actions.increment());
}, milliseconds);
},
openDialog() {
fetch().then(dispatch(actions.openDialog()));
}
});
const reducer = (state) => ({
increment(num) {
state: state.value + num
},
openDialog(abc) {
}
});
// @run({
// action, reducer, initialState, namespace, mapStateToProps
// })
const ShopOverviewCard = React.Component({
PropTypes: {
device: React.PropTypes.number
},
render() {
return (
<div onClick={this.props.increment.bind(this, 10)}>Value: {this.props.counter}</div>
<button onClick={this.props.incrementAsync(100)}>Increment Async</button>
)
}
})
export default run({
view: ShopOverviewCard, action, reducer, initialState, namespace, mapStateToProps
})
License
MIT