react-webpack-rails-tutorial
react-webpack-rails-tutorial copied to clipboard
Convert from redux-thunk to redux-saga
I'm looking for opinions here.
At team ShakaCode, we're using redux-saga rather than redux-thunk for new projects.
Options:
- Move existing code to redux-saga, and keep a non-router version of the code using redux-thunk. Basically, one more tab.
- Switch all the code to redux-saga.
References:
- http://survivejs.com/blog/redux-saga-interview/
- https://shift.infinite.red/using-redux-saga-to-simplify-your-growing-react-native-codebase-2b8036f650de#.jv5y7sgs1
- http://stackoverflow.com/a/34933395/1009332
Check out this tutorial I made: https://forum.shakacode.com/t/experimenting-with-generators/657
As of right now, Thunk is easier to understand and debug. See #315. We should probably make a new project with thunk.
That being said, it's a great exercise to convert the 2 simple async calls to thunk in a PR.
I'll look at this issue
See #325
Just curious, do you all find the conceptual overhead of redux-saga worth it?
I've used Thunks extensively in a production application, and have had no issues or complaints.
In terms of testability, it still seems like you have to manipulate generator internals, which seems like a leaky abstraction.
With Thunks, it seems like it would be possible to mock out XHR via Jest which would seem more straightforward.
I've also heard from less experienced members on my team that sagas were tough to debug and not as straightforward to use as Thunks.
Again, I don't have direct experience with sagas, just looking for an opinion from someone that's used both.
@yangmillstheory You should be able to mock either the saga or thunk with jest. In terms of debugging, yes, the chrome debugger is not good inside of the generator function. You have to use print statements. I think they are both good ways.
This one should have gotten merged. Any takers that want to create an updated PR with this?