發表文章

目前顯示的是 6月, 2016的文章

[ Javascript ] CTJS Note

圖片
Redux設計概念與實戰 Redux 簡報:  http://slides.com/dmoon/redux-intro# Why   SPA more complecated   data跟view分開, 類似angular, data只有一份,data changed -> view changed React:   data and view bind Problem:   props傳遞地獄 Redux   predictabble state container  三大原則 Single source of truth 單一資料來源 整個應用的state存在一顆object tree中,並放在唯一的container(state)內 State is read only 唯一改變state的方法就是觸發action(修改資料唯一方法) Redux Flow    Produc -> 畫面需要改變 -> 產生action                                                                   |                                           Server <- action -> dispatch -> reducer                                                                                                            |                                                                                           return newState -> 資料變更&view重繪 Action js obj type是必要的,表示 要執行的動作 包含事件的描述與更新state所需要的相關資料 Action Creter pure function, return an action dispatch到reducer