DTUX – 前端开发-小威
状态是指,Web应用中需要共享和通信的数据对象。状态管理是指用一种通用且合理的方式来组织维护这些状态。
状态管理(State Management)
Domain data
源于服务端对领域模型的抽象,比如user、projects
UI State
描述UI组件的展示状态,例如visible, selected
App State
例如应用的router信息,http请求状态等
// reducerA.js
export const reducerA = (state = '', action) => {
switch(action.type) {
case "GET":
return action.data
default:
return state
}
}
// reducerB.js
export const reducerB = (state = '', action) => {
switch(action.type) {
case "GET":
return action.data
default:
return state
break;
}
}
// mainReducer.js
import { combineReducers } from 'redux';
import { reducerA } from './reducerA'
import { reducerB } from './reducerB'
export const mainReducer = combineReducers({
reducerB,
reducerB,
})
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.
| - state
| - routing
| - req
| - user
| - projects
| - projectUsers
| - realtimeTask
| - tabs
| - taskTree
| - resourceTree
| - currentTab
| - offlineTask
| - taskTree
| - resourceTree
| - functionTree
| - sysFunctionTree
| - workbenchTree
| - dataSync
| - sqlEditor
| - comm
| - visibleTask
| - visibleCata
| - ...
| - reducers.js
| - modules
| - comm
| - req.js
| - visible.js
| - realTimeTask
| - index.js
| - tabs.js
| - taskTree.js
| - resourceTree.js
| - currentTab.js
| - offlineTask
| - index.js
| - taskTree
| - resourceTree
| - functionTree
| - sysFunctionTree
| - workbenchTree
| - dataSync
| - sqlEditor.js
| - user.js
| - projects.js
| - projectUsers.js
| - ...