An Introduction to Redux Saga

According to the docs, redux-saga is a library that aims to make application side effects (i.e. asynchronous things like data fetching and impure things like accessing the browser cache) easier to manage, more efficient to execute, simple to test, and better at handling failures.

Why You Should Use Redux Saga

Redux became the popular and standard for state management in ReactJS applications. Redux provides an interface for dispatching actions to reducers which leads to transitions between states that other components (or Sagas) may react to. Redux Saga is an approach to the organization of side effects. It allows you to write asynchronous events in a clear and declarative style without callbacks.

Benefits of Redux sagas

  • Simplicity of testing
  • Declarative style
  • Simplicity in organizing difficult side effects sequences

How does redux-saga work?

Sagas are implemented using generator functions (a new ES6 feature). Unlike normal functions which run to completion and return a final value, generator functions can be paused and resumed on demand and can return (more accurately yield) multiple values.

Check the official website for more details
https://redux-saga.js.org/

Useful links
https://github.com/redux-saga/redux-saga/tree/master/examples
https://flaviocopes.com/redux-saga/
https://hackernoon.com/redux-saga-tutorial-for-beginners-and-dog-lovers-aa69a17db645

 

3 thoughts on “An Introduction to Redux Saga”

    1. Redux-Thunk and Redux-Saga are both middleware libraries for Redux. The difference is Redux-Thunk can never act in response to an action. On the other hand, Redux-Saga subscribes to the store and can trigger a saga to run or continue when a certain action is dispatched.

Leave a Reply

Your email address will not be published. Required fields are marked *