waef-reactkit
waef. Using React,Redux,Redux Saga
react small startKit forInstall
$ npm install waef-reactkit$ npm install react react-dom
Usage
; app; // regist react routes.usage same to react-redux. eg see belowapp; // regist models;app;// app.registModel(others); //start app appstartrootId;//rootId default 'root'
route sample
;;//important;; { return <Router history=history> <Route path='/' component=App> <IndexRoute component=Index /> </Route> </Router>}
model sample
;; { super'modelDemo' //set model name to modelDemo pageIndex: 1 pageSize: 10 totalCount: 0 items: // initial state reducers = { const that = this; return { // you can call that.getState() to get curr state const uid = payload; const items = stateitems; const totalCount = that; for let i = 0 len = itemslength; i < len; i++ if itemsiuid === uid items = items; break; return Object; } // other reducers.these reducers can effect in time // each reducer must return a json object like state defined } effects = { const that = this; return { // you can call that.getState() to get curr state const pageIndex = payload; const pageSize = that; const items = ; that } // other effects.these effects need ajax or async // you can call that.setState(newState) to update curr state } actions = { const that = this; return { return that; } { return that; } // createAction(reducer/effect name,payload); } } const model = ;app;// regist model. important // you can call model.getState() or model.setState() everywhere;
redux connect
;;//important const App = { return <div> children </div> }ApppropTypes = {} App;// api same to react-redux
License
MIT