支持saga、redux的数据流框架
const reducer = (state = {}, action) => {
switch (action.type) {
case "ADD":
return {
...state,
count: ++state.count
};
case "MIN_NUM":
return {
...state,
count: --state.count
};
default:
return state;
}
};
export default reducer;
combineReducers({
a,
b
})
import Provider, { createStore } from '@ali/lexo';
import reducer from './reducer';
const store = createStore(reducer);
App(Provider(store)({}));
const createStoreWithSaga = applyMiddleware(
createLogger(),
sagaMiddleware(saga)
)(createStore)
const mapStoreToProps = ({ count }) => { count };
Component(connect(mapStoreToProps)({
didUnmount() {
}
}));
export const fetchList = ({ data } = {}) => async (dispatch, getState) => {
try {
dispatch(updateTodo({
data
}));