redux-rex

A microframework to write reusable components based on Redux.

Usage no npm install needed!

<script type="module">
  import reduxRex from 'https://cdn.skypack.dev/redux-rex';
</script>

README

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