新人日报1129
=====看到想砸墙======
@MobX
Better order:
Overview First:https://mobx.js.org/intro/overview.html
Getting Started:https://mobx.js.org/getting-started.html
Simple state management
reactive view to observable state.
State can include: domain specific state && view state
**derivation: Can be derived from state, without any further interaction && declared with ‘@computed’
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方法才会遍历下一个内部状态