新人日报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方法才会遍历下一个内部状态

相关文章
相关标签/搜索