redux-fool
New APIs in v0.4.
It is compatibile with v0.3.x action/reducer declaration.
Install
npm install redux-tool --save
How fool it is?
- Provide a good practice of global state design referred to standard-redux-shape.
- Replace actionType + action + reducer with simple
model
configure.
Quick Start
index.js
;;;; ;; const models = todo ; // compatible with v0.3const reducers = todo: todoReducers ; const store = ; const Root = <Provider store=store> <App /> </Provider>; ReactDOM;
model.js
;; const todo = state: {} // initial state // configure async actions requests: getTodos: // a Promise, usually a api call request // advanced configs, refer to https://github.com/ice-zjchen/redux-fool/blob/master/docs/utils.md#makeAsyncActionCreator withTableUpdate: tableName: 'todoById' resuuid: res 'all' cocurrent: false once: false null // configure reducers of sync actions handlers: { // do something here return state; } ; ;
List.js
;; ; { // dispatch action thispropsactions; } { <a onClick=thisretrieveTodos> Retrieve All Todos </a> } const mapStateToProps = state; const mapDispatchToProps = actions: ...dispatchtodo // actions in `dispatch` object ...todoActions // compatible with v0.3 ; mapStateToProps mapDispatchToPropsList;