5
Redux-Saga实践
source link: http://muyunyun.cn/blog/iyizcnh2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
来看为什么有如下 api:
call/put
本质目的是让测试用例不必再发起多一次函数调用, 取而代之转为比较对象是否相同。
- 使用
call
替代使用fetch
- 使用
put
替代使用dispatch{action}
- 使用
fork
: 模拟多个线程
redux-saga 相较于 redux-thunk 的一些优点
- 对测试用例较为友好(比较函数和传入参数)
- 对异步操作流程的操作颗粒度更加细
Powered by Create React Doc.
100962|130626
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK