[英]Which one is best to use Redux-thunk or redux-saga
I am very new to this redux.developed a project in flux now thought of upgrading it .I have used many API calls to get the data and used stores to get and retrieve data. 我对这个redux并不陌生。我开发了一个flux项目,现在正在考虑对其进行升级。我使用了许多API调用来获取数据,并使用存储来获取和检索数据。 Can any one suggest me to use the right one either thunk or saga In some blogs it was written to use MobX too.
任何人都可以建议我使用正确的thunk或saga。在某些博客中,也写过也使用MobX。
I think the choice between the two depends on the product requirements. 我认为两者之间的选择取决于产品要求。 For simple UIs where there is simple data flow from a server response to react component, then just using thunk should suffice.
对于简单的UI,从服务器响应到响应组件只有简单的数据流,那么仅使用thunk就足够了。 For more complicated async interactions (where there needs to be coordination between react components), sagas can help out quite a bit by providing structure to your code.
对于更复杂的异步交互(在React组件之间需要协调),sagas可以通过为代码提供结构来帮助很多。 There is some amount of learning curve with sagas so you might want to start very small and make sure you have plenty of test coverage for all your assumptions.
Sagas有一些学习曲线,因此您可能希望从很小的角度入手,并确保所有假设的测试覆盖面都广。 Redux Saga Test Plan is great at helping you test your sagas.
Redux Saga测试计划非常适合帮助您测试Sagas。
For my current project, we started with thunk then transitioned to saga because our use cases were complex enough to leverage the benefit of sagas. 对于我当前的项目,我们从笨拙开始,然后过渡到传奇,因为我们的用例足够复杂,可以利用sagas的好处。
I have not used MobX so I can't comment on that. 我没有使用过MobX,因此无法对此发表评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.