The majority of projects use Redux Thunk to organize side effects. In principle, it gives a good result: it’s easy to read and test the code (but you still need to mock network requests). But it all is fair as far as the logic of your action creators (or thunks) is simple. Unfortunately, for more than a few functions the code becomes harder to read, which makes it even more difficult to test.
In this situation, Redux Saga comes to the rescue. Redux Saga is an alternative approach to the organization of side effects. Instead of dispatching functions processed by Redux Thunk you create saga and write all the logic of event stream processing. Unlike thunks that are carried out when you dispatch them, sagas run in the background right after the app is launched. Sagas observe all actions that the store dispatches and decide what to do with them.
At this point, we can allocate three key benefits of sagas:
- Simplicity in organizing difficult side effects sequences;
- Declarative style;
- The simplicity of testing.
If you want to know how to put saga into practice, check our article: https://blog.s-pro.io/use-redux-saga/ where you'll find code examples and much more!