redux-rex

0.1.0-alpha-9 • Public • Published

Rex

A microframework to write reusable components based on Redux.

Overview

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

Readme

Keywords

none

Package Sidebar

Install

npm i redux-rex

Weekly Downloads

0

Version

0.1.0-alpha-9

License

MIT

Last publish

Collaborators

  • arcthur
  • camsong
  • hzongquan
  • twobin