简体   繁体   English

哪个最好使用Redux-thunk或redux-saga

[英]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.

相关问题 为什么要使用redux-thunk或redux-saga来获取? - Why use redux-thunk or redux-saga for fetches? Redux-Thunk到Redux-Saga - Redux-Thunk to Redux-Saga 如何在另一个 redux-saga 结束时调用一个 saga 就像在 redux-thunk 中异步等待一样 - How to call one saga at the end of another redux-saga like a async await in redux-thunk React-Redux有几种使用方法? Redux-thunk vs Redux-Saga? - How many methods are there to use React-Redux? Redux-thunk vs Redux-Saga? 将关于redux-thunk的操作复制到redux-saga - Replicating the action on redux-thunk to redux-saga 关于没有中间件的Redux Async(redux-thunk,redux-saga ...) - About Redux Async without middleware (redux-thunk, redux-saga… ) 一种在不使用 redux-thunk 或 redux-saga 中间件的情况下处理 Redux 存储上的异步状态更新的方法? - A way to handle async state updates on Redux store without using redux-thunk or redux-saga middleware? 在中间件即 redux-thunk 或 redux-saga 中运行异步代码有什么好处 - What is the advantage of running asynchronous code in middleware i.e. redux-thunk or redux-saga 使用带有 ES6 生成器的 redux-saga 与带有 ES2017 async/await 的 redux-thunk 的优缺点 - Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/await 使用redux-thunk和redux-observable - use of redux-thunk with redux-observable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM