首页 > 其他 > 详细

新人日报1129

时间:2017-11-30 11:39:49      阅读:281      评论:0      收藏:0      [点我收藏+]

=====看到想砸墙======

@MobX 

 

Better order

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

Getting Startedhttps://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方法才会遍历下一个内部状态

新人日报1129

原文:http://www.cnblogs.com/ariel-zhang/p/7927577.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!