You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// NavActionCreators.jsexportdefault{clickNav(nav){AppDispatcher.dispatch({type: ActionTypes.CLICK_NAV,
nav
});}};
dispatcher --> store callback
AppDispatcher.register(action=>{switch(action.type){// nav点击caseActionTypes.CLICK_NAV:
IndexWebAPIUtils.getGiftList(_currentUserInfo.userId,action.nav.id).then(function(giftList){_currentGiftList=giftList;IndexStore.emitChange();});break;// no default}});
React Flux架构简介
React简介请戳这里
Flux是什么
Flux的核心部分
dispatcher
store
view
其他
How Flux(Unidirectional Data Flow) Works
view --> actionCreators
action dispatch
dispatcher --> store callback
store emitChange --> controller view --> setState
Flux vs MVVM
MVVM
Flux
Flux的优势
数据状态变得稳定同时行为可预测
所有的数据变更都发生在store里
数据的渲染是自上而下的
view层变得很薄,真正的组件化
dispatcher是单例的
Flux的困境
过多的样板代码
dispatcher是单例
异步处理到底写在哪里
至今还没有官方实现
写在最后
The text was updated successfully, but these errors were encountered: