新人日報1129

=====看到想砸牆======html

@MobX react

 

Better ordergit

Overview Firsthttps://mobx.js.org/intro/overview.htmlgithub

Getting Startedhttps://mobx.js.org/getting-started.htmlredux

 

Simple state management數據結構

reactive view to observable state.dom

State can include: domain specific state && view stateasync

 

**derivation: Can be derived from state, without any further interaction && declared with ‘@computed’ide

computed(function) creates functions that only re-evaluate if it has observers on its own, 函數

**reaction: need to achieve I/Os, don’t produce new values && execute with ‘autorun()’

只有在reaction的 dependencies 發生變化須要更新的時候,纔會執行,

 

@action的表示有點相似Redux中container component和presentation component的分別

 

----------------------------------------

都是先定義state的shape,any data structure

Redux作到的事讓觸發state改變的action可控,

MobX的action更靈活,監控state中observable變量的變化,經過’@observer’ 定義component,來自動檢測變化,來作到最小更新

 

 

-------

Async action in Redux:::

With asynchronous code, there is more state to take care of。How to organize it in a single tree

 

Use the redux-saga middleware to build more complex asynchronous actions.

 

-------

MiddleWare

Provide third-party extension between 「dispatch actions」 & 「the moment it reaches Reducers」

 

———————

Redux-saga: a middleware,  用generator的語法寫的

 

-------

Iterator 接口的目的,就是爲全部數據結構,提供了一種統一的訪問機制

Generator函數:是一個狀態機,並返回一個遍歷器對象。 調用函數的時候不會執行,是返回一個指向內部狀態的指針。只有調用next方法纔會遍歷下一個內部狀態

相關文章
相關標籤/搜索